TUTORIALS :: How to submit your Linux Kernel Patch
Written by: Shyam Saini, edited by Kiran Kankipati - Published: 07-Feb-2017
If you are a newbie or even an experienced programmer you might have stumbled at
kernel newbies page
which is heaven for all those who are willing to involve in Linux kernel development.
Today I'm writing about linux kernel patch Philosophy. Oh yes, You are right submitting kernel patches is none less than a Philosophy.
In fact there is a good post about Patch Philosophy.
It is more about Linux development culture which follows certain rules and norms for the patch and if you are newbie you better
follow this culture to make your life easier.
Scared or Worried? Don't worry. Rule of the game is:
- be patient
- read blogs written by various developers to get the bigger picture
- ask your queries on kernelnewbies mailing list.
But again do your research first. That will help you a lot.
Kernel maintainers stay very busy and receive many patches in a single day. Obviously you won't like to make bad impression by sending wrong/invalid patches.
Here wrong/invalid has huge meaning. I'll try to state all those:
* patch which is not tested
> Never send a patch which is not built successfully.
* patch built(compiled) against wrong wrong tree or outdated tree.
> Newbies are most prone to do these mistakes.
* why should you bother about these trees?
> It might happen that the patch which you are sending is already been sent by someone else and thus your patch would be of no use.
> And It may happen the maintainer won't reply for such obsolete patch.
* which git tree to use ?
> Always use linux-next tree unless and until
it is explicitly mentioned to use other trees.
> Sometimes we might need to work against different trees of different subsystems.
Again always choose trees ending -next*.
For more details about -next* kindly read this document.
* Never send patch or patch-set with exactly same commit header or similar commit.
> Commit header lets the other developers what changes has been made in two or more constructive commits. For example:
[PATCH 1/3] dgnc: Fix the Z
[PATCH 2/3] dgnc: Fix the Z
[PATCH 3/3] dgnc: Fix the Z
or say for example:
[PATCH 1/3] dgnc: Fix the Z
[PATCH 2/3] dgnc: Z is fixed
*So what is the right way?
> Whenever you get stuck in such a situation where you are fixing same thing but in different files of same subsystem or driver
then always try to send all the changes in a single patch instead of sending different patches with same or similar commit
Last but not least, after building and testing always check you patch with following scripts checkpatch.pl which is present in
your kernel source tree scripts/checptach.pl
Here is an example where I've tested a patch named 0001-qed-Replace-memset-with-eth_zero_addr.patch
mystictot (my-1016) linux-tree $ ./scripts/checkpatch.pl 0001-qed-Replace-memset-with-eth_zero_addr.patch
total: 0 errors, 0 warnings, 0 checks, 33 lines checked
0001-qed-Replace-memset-with-eth_zero_addr.patch has no obvious style problems and is ready for submission.
So, if you get the same output as has no obvious style problems and is ready for submission, then everything is good with
your patch. Now, you are all set to send your patch.
All the best ;)
For example here are my Kernel submission log screenshots:
(API) Watch Video: 0x1a9 Become a Windows or a Linux Programmer ? || The Linux Channel* Click the image to watch this video on Youtube ↗