Kernel submission
Commands and advice before sending to LKML
Having a patch ready for the kernel need some attention. To have the best chances for your patch to be accepted, you have to read
Documentation/SubmittingPatches or https://www.kernel.org/doc/html/latest/process/submitting-patches.html
Links
kernel_patch_tutorial by GregKh
More recent way with the b4 tool
Here is a resume of the commands you may have to use
Setup Sources
Patch should be build against linux-next branch Detailed informations
Get Sources
$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git # or: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git Cloning into 'linux'... $ cd linux $ git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git # or: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git $ git fetch linux-next ... $ git fetch --tags linux-next ...
Update Sources
$ git checkout master # to be safe ... $ git remote update ...
Start branch
$ git tag -l "next-*" | tail next-20140612 next-20140613 ...
$ git checkout -b my_local_branch next-20140625 Switched to a new branch 'my_local_branch'
Sources indentation and style
First follow coding style rules describe in
Documentation/CodingStyle
You can correct your indentation using
scripts/Lindent MyFile.c
Make sure that the compilation do not produce unjustified warning
make
And check that you follow the recommended rules
scripts/checkpatch.pl --strict -f MyFile.c
Or a given commit
scripts/checkpatch.pl -g HASH
Commit message
Current code does (A), this has a problem whith (B). We can improve this doing (C°, because (D).
Rebase your work
git fetch --all --tags git rebase [origin/master]
Create the patch
Once checkpatch is ok with your file, you can create the patch to send using git.
- Commit your modification ( cf. Documentation/SubmittingPatches for the commit message) on a dev branch
- Create the patch
git format-patch -o patches --subject-prefix="PATCH" -s COMMIT-ID
or for second patch version
git format-patch -o patches --subject-prefix="PATCHv2" -s COMMIT-ID
-s is for sign-off -n will generate numbered patches in [PATCH n/m] format, even with a single patch. –cover-letter will generate a cover letter file so that you can fill in the description for your entire set of patches. If you only have one patch, you should skip this.
The files generated in patches directory could be check using
scripts/checkpatch.pl --strict my_patch.patch
Send the patch
Then you can send the patch to the lkml.
Destinataires are describe in Documentation/SubmittingPatches. In short, do not forget to CC linux-kernel@vger.kernel.org and the dest could be find using
scripts/get_maintainer.pl path_to_file_i_modify
To send it, you can use a mail client. Mail should be in plain text and patched included in the mail corp (once again cf. Documentation/SubmittingPatches).
You can also use the git send-email tool (As this module is optional on the distribution, it may require additional installation). You need to configure git and add in ~/.gitconfig
[sendemail] smtpencryption = tls smtpserver = smtp.gmail.com smtpuser = yourname@gmail.com smtpserverport = 587
then you can send the mail, with all the patches in the "patches" directory created by git format-patch
git send-email --annotate patches
Other Links
- http://www.labbott.name/blog/2016/08/15/ideas-for-getting-started-in-the-linux-kernel/
- PGP with kernel
- Work with patch from inbox: https://memcpy.io/applying-mailing-list-patches-with-git-b4.html
- More patch tools: https://josefbacik.github.io/kernel/2021/10/18/lei-and-b4.html
- tools: https://people.kernel.org/monsieuricon/lore-lei-part-2-now-with-imap, https://people.kernel.org/monsieuricon/lore-lei-part-1-getting-started
- b4, mutt and tools: https://www.kraxel.org/blog/2021/11/patch-mail-b4-notmuch/