Science and technology

Steps for contributing to the Linux Kernel

One of the largest—and the quickest shifting—open supply initiatives, the Linux kernel, consists of about 53,600 information and practically 20-million strains of code. With greater than 15,600 programmers contributing to the venture worldwide, the Linux kernel follows a maintainer mannequin for collaboration.

In this text, I am going to present a fast guidelines of steps concerned with making your first kernel contribution, and have a look at what it is best to know earlier than submitting a patch. For a extra in-depth have a look at the submission course of for contributing your first patch, learn the KernelNewbies First Kernel Patch tutorial.

Contributing to the kernel

Step 1: Prepare your system.

Steps on this article assume you’ve got the next instruments in your system:

Step 2: Download the Linux kernel code repository:

git clone -b staging-testing
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git

Copy your present config:

cp /boot/config-`uname -r`* .config

Step three: Build/set up your kernel.

make -jX
sudo make modules_install set up

Step four: Make a department and swap to it.

git checkout -b first-patch

Step 5: Update your kernel to level to the most recent code base.

git fetch origin
git rebase origin/staging-testing

Step 6: Make a change to the code base.

Recompile utilizing make command to make sure that your change doesn’t produce errors.

Step 7: Commit your modifications and create a patch.

git add <file>
git commit -s -v
git format-patch -o /tmp/ HEAD^

The topic consists of the trail to the file identify separated by colons, adopted by what the patch does within the crucial tense. After a clean line comes the outline of the patch and the obligatory signed off tag and, lastly, a diff of your patch.

Here is one other instance of a easy patch:

Next, ship the patch using email from the command line (on this case, Mutt):

mutt -H /tmp/0001-<no matter your filename is>

To know the listing of maintainers to whom to ship the patch, use the get_maintainer.pl script.

What to know earlier than submitting your first patch

  • Greg Kroah-Hartman‘s staging tree is an efficient place to submit your first patch as he accepts straightforward patches from new contributors. When you get conversant in the patch-sending course of, you might ship subsystem-specific patches with elevated complexity.
  • You additionally may begin with correcting coding model points within the code. To study extra, learn the Linux kernel coding style documentation.
  • The script checkpatch.pl detects coding model errors for you. For instance, run:
    perl scripts/checkpatch.pl -f drivers/staging/android/* | much less
  • You may full TODOs left incomplete by builders:
    discover drivers/staging -name TODO 
  • Coccinelle is a useful instrument for sample matching.
  • Read the kernel mailing archives.
  • Go by means of the linux.git log to see commits by earlier authors for inspiration.
  • Note: Do not top-post to speak with the reviewer of your patch! Here’s an instance:

    Wrong approach:

    Chris,
    Yes let’s schedule the assembly tomorrow, on the second flooring.
    > On Fri, Apr 26, 2013 at 9:25 AM, Chris wrote:
    > Hey John, I had some questions:
    > 1. Do you wish to schedule the assembly tomorrow?
    > 2. On which flooring within the workplace?
    > three. What time is appropriate to you?

    (Notice that the final query was unintentionally left unanswered within the reply.)

    Correct approach:

    Chris,
    See my solutions under…
    > On Fri, Apr 26, 2013 at 9:25 AM, Chris wrote:
    > Hey John, I had some questions:
    > 1. Do you wish to schedule the assembly tomorrow?
    Yes tomorrow is okay.
    > 2. On which flooring within the workplace?
    Let’s preserve it on the second flooring.
    > three. What time is appropriate to you?
    09:00 am can be alright.

    (All questions have been answered, and this fashion saves studying time.)

  • The Eudyptula challenge is a good way to study kernel fundamentals.

To study extra, learn the KernelNewbies First Kernel Patch tutorial. After that, in the event you nonetheless have any questions, ask on the kernelnewbies mailing list or within the #kernelnewbies IRC channel.

Most Popular

To Top