Recently, I needed to submit a patch to Linux kernel. After waiting for a long time, my patch finally got merged into Linus tree. 🥳
I found that the Linux development process is quite different from other open source projects. So, I decided to write down how it works.
Linux Development Process Concept
Linus Torvalds maintains a Linux source repo. He releases the new version Linux kernel regularly. Also, when a new version is released, he’ll split a new branch and the stable tree maintainer will take care of the new branch.
So, what could we do if we want to add code into Linus tree?
Intuitively, it’s really simple. Just send a email to Linus and say
- please git pull my repo
- please commit my patch
These two methods are actually feasible. However, the codebase of Linux is quite large. There are many sumbits each day. It’s not practical for Linus to handle all the sumbits by himself.
Hence, there are different maintianers and reviewers of each subsystem and file. A subsystem ususally has its own Linux repo. Every new changes in the subsystem will be committed into the subsytem tree first. And when Linus’s merge window is opened, subsystem mainainter will send pull request to Linus.
So, if we want to add code to Linus repo, all we have to do is sending a patch to the subsystem maintainer.
How to Submit Patch
The whole process looks like this
- We send a patch to the subsystem maintainer
- Subsystem maintainer commits the patch into subsystem tree
- Subsystem maintainer sends pull request to Linus
- Linus merges
Therefore, in order to get our code into Linus repo, we’ll need at least two approvals. Which are from
- Subsystem maintainer
- Linus
How do we know what should we do to get their approvals?
- For Linus, we can reference this document
- For subsystem maintainer, each subsystem has its own document. e.g. nerworking’s document
Since each subsystem has its own rule, I only describe how to send a general patch. Primary, We can reference this document
For simplicity, I divide the process into five steps
- First step, add
Signed-off-by NAME <EMAIL>
into your commit message. It shows that you signed the Linux’s Developer Certificate of Origin. - Second step, use
git format-patch master..your_branch
to generate patch file. - Third step, check is there improper style in the patch using checkpatch.pl.
- e.g.
./scripts/checkpatch.pl 0001-xxxxxx-xxxxx.patch
- e.g.
- Fourth step, find which maintainer we should email to using get_maintainer.pl
- e.g.
./scripts/get_maintainer.pl 0001-xxxxxx-xxxxx.patch
- Note: We should send to at least a maintainer and a open mail list.
- e.g.
- Fifth step, send the patch via email.
git send-email --to xxx@kernel.org --cc xxx@vger.kernel.org 0001-xxxxxx-xxxxx.patch
After sending the patch, we can communicate with maintainer through replying the email. (note: you’ll need to witch to plain text mode if you’re using gmail.)
Appendix
Appendix A: Archives of mail list
http://vger.kernel.org/vger-lists.html
Appendix B: Submit patch into stable tree
Stable tree is maintained by Greg Kroah-Hartman. We can reference this document
Appendix C: Revise the patch
We can’t send the revised patch in the same email thread. We have to send a new email witch PATCH v2
as the prefix.
git format-patch --subject-prefix='PATCH v2' master..your_branch