Linux kernel has become one of the most gigantic and complex software project in the world, its complication scare many novices away. In this post, I will give some personal experience on how to learn
Linux kernel, and hope these tips can offer some help to newcomers.
(1) Download vanilla kernel and install it.
Yes, I suggest you can find a physical machine, or if you really don’t have one at hand, virtual machine is also OK. Download the newest vanilla kernel from kernel.org, then build and install it. This process isn’t too hard and makes you conquer the fear of Linux kernel. After your first successful setting up of
Linux kernel, and read the release version number from
uname -r output:
# uname -r
I think this will enable you gain more confidence.
(2) Study the elementary skills of
Linux kernel programming.
Looking back when you begin user-space C programming on
*nix platform, you need to know allocating memory through
malloc; opening file through
pthread library to construct concurrent program, and so on.
Linux is nothing more than a platform, and you also need to study the rules of playing with it. For example, you should be familiar with how to tweak list (
list.h); giving out memory should use
kmalloc, etc. There are many classical books and tutorials elaborate these knowledge. Although some posts seem outdated (the version of kernel is still
2.6.x.), but they are also applicable to current.
(3) Dive into one module.
Once you get the basic expertise of
Linux kernel programming, you should focus on one aspect of the kernel. If you are a full-time kernel programmer, congratulations! You should concentrate on your work area and try to be the expert of this domain. If kernel is just your hobby, you should select one module which you have great interest on. I.e., if you are curious about debugging,
kdump should be your taste; if you pay close attention to dynamic tracing,
BPF will be the right stuff which you want to find. After picking out the part you want to contribute, you should dig into the code and attempt to master every detail of it. You should also subscribe the related mailing list to acquaint the newest progress. The final goal is to check in meaningful patches for kernel, from a trivial typo to an enhanced feature. Think your code will run on millions of thousands of devices, it is really amazing!
When you meet an issue, you can try to get help from mailing list or forums. You can also try to take part in local community to recognize people in the same camp. Anyway, Endeavor to utilize all the resource you can find.