TUTORIALS 》 How to submit your Linux Kernel Patch

This article is submitted by my student:
If you want to feature your article, you can kindly contact me via email and send your article submissions (content and the resources). Once they are reviewed, I should accept and post the same 🤗

2 - Shyam Saini, Delhi, Montreal, Quebec, India, Canada ↗
LinkedinGithubTwitter 🔗
Consultant en logiciel libre (Free Software Consultant) at Savoir-faire Linux
DevOps Engineer at Paytm ↗, FOSS, Kernel programmer and Linux enthusiast

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 header.

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:
Link: http://git.netfilter.org/iptables/log/?qt=grep&q=shyam+saini
Shyam Saini Kernel patch submissions
Shyam Saini Kernel patch submissions
Shyam Saini Kernel patch submissions
Shyam Saini Kernel patch submissions


Featured Video:

Suggested Topics:

☆ Tutorials :: Arduino UNO Projects ↗

☆ Tutorials :: Network Software Development ↗

☆ Tutorials :: Research and Projects ↗

☆ Tutorials :: Linux (user-space), Systems Architecture ↗

☆ Tutorials :: Linux Kernel Software Development ↗

☆ Tutorials :: Linux Kernel Internals (PDFs) - by Ramin Farajpour ↗

☆ Tutorials :: Software Development (Programming) Tools ↗

☆ Tutorials :: Embedded Projects ↗

Join The Linux Channel :: Facebook Group ↗

Visit The Linux Channel :: on Youtube ↗

💗 Help shape the future: Sponsor/Donate

Recommended Topics:
Featured Video:
Watch on Youtube - [952//0] x256 Network Sockets | Big Picture | User-space to Kernel-space Networking Subsystem ↗

What is purpose of Kernel Development - Example SMOAD Networks SDWAN Orchestrator Firewall Kernel Engine ↗
Monday' 18-Jul-2022
Often aspiring students may have this question, that what is the purpose of Linux Kernel Development. Since Linux Kernel is very mature and it has almost everything one would need. Usually, we need custom kernel development in the case of any new driver development for new upcoming hardware. And this happens on and on. But at times we may also come across few features/modules/components which are already provided by the Linux Kernel which are not adequate or atleast not the way we exactly intended to use. So, this is the real-world example, sometimes no matter what Linux Kernel provides as a part of stock Kernel/OS features, sometimes we have to write our own custom kernel stack or module(s) which can specifically cater our exact needs.

Roadmap - How to become Systems Software Developer ↗
Friday' 13-May-2022
When you are at the beginning of your career or a student, and aspire to become a software developer, one of the avenues to choose is to become a hard-core Systems Software Developer. However it is easier said than done, since there are many aspects to it as you explore further. As a part of systems developer, you can get into core kernel space developer, kernel device drivers developer, embedded developer and get into things like board bring-up, porting, etc, or can become a user-space systems programmer, and so on. So here is my detailed multi-episode Youtube video series on Roadmap - How to become Systems Software Developer.

The Linux Channel :: Sponsors ↗
Monday' 30-May-2022
Here is a list of all The Linux Channel sponsors/donors (individual/companies).

Linux Kernel vs User-space - Library APIs - Linux Kernel Programming ↗
Tuesday' 17-Jan-2023
One of the important aspects a beginner who is into Linux Kernel space systems software development has to understand is that unlike user-space C/C++ programming, where you can freely include any library APIs via respective #include files (which are dynamically linked during run-time via those /lib .so files), in the case of Kernel space programming, these library APIs are written within the Kernel source itself. These are the fundamental APIs which we commonly use, such as memcpy(), memcmp(), strlen(), strcpy(), strcpy() and so on. So here is my detailed Youtube video episode on the same with live demo, walk-through and examples.

Linux Kernel Driver Device Trees ↗
Tuesday' 17-Jan-2023
The Linux kernel is the backbone of the Linux operating system. A device tree is a hierarchical tree structure that describes the various devices that are present in a system, including their properties and relationships to one another. The device tree is used by the Linux kernel to identify and initialize the different devices on a system, and to provide a consistent interface for interacting with them.

Linux Kernel /sysfs Interface ↗
Saturday' 14-May-2022
/sysfs is one of the most popular kernel to user-space interface which you can leverage to add an interface to your Kernel code such as Kernel modules, Kernel Device Drivers, etc. Although personally I prefer /proc interface than other alternatives such as /sysfs, ioctl() and so on for my personal Kernel modules/stack. So here is my detailed multi-episode Youtube video series on /sysfs Interface.

Rockchip ROC-RK3566-PC from Firefly | OpenWRT ↗
Monday' 23-Jan-2023
Here is my multi-episode video series on evaluation of Rockchip ROC-RK3566-PC from Firefly with stock OpenWRT firmware.

Support, Donate and Contribute - The Linux Channel ↗
Saturday' 13-Mar-2021
Help shape the future and make an impact by donating/sponsor The Linux Channel. Your donation will transform lives !

Research Socket overhead in Linux vs Message Queues and benchmarking ↗
Saturday' 13-Mar-2021

Linux Kernel Data-Structures ↗
Saturday' 13-Mar-2021
Here is a quick reference of important Linux Kernel Data Structures of various assorted Kernel Subsystems such as: Process, Memory Management, Networking, File System, Device Drives, IPC and so on. So when you write custom Kernel code, it is often you may need to populate a new instance of one of these data-structures or just access the existing ones. Hence it is very important to know some of these and get familiarized with. You can bookmark this page, so that you can use this as a quick reference when you write your own custom Linux Kernel Modules.

Trending Video:
Watch on Youtube - [853//0] 0x18c Architecting | Process and Threads | Part 1/2 | The Linux Channel ↗

Tour of my new Home Networking Lab within VirtualBox VM ↗
Saturday' 13-Mar-2021

Recommended Video:
Watch on Youtube - [498//0] 0x1a7 My Research - My Rules | Promiscuous Mode | Network Protocol Architecture | The Linux Channel ↗