2.How the development process works

Linux kernel development in the early 1990’s was a pretty loose affair,with relatively small numbers of users and developers involved. With auser base in the millions and with some 2,000 developers involved over thecourse of one year, the kernel has since had to evolve a number ofprocesses to keep development happening smoothly. A solid understanding ofhow the process works is required in order to be an effective part of it.

2.1.The big picture

The Linux kernel uses a loosely time-based, rolling release developmentmodel. A new major kernel release (which we will call, as an example, 9.x)[1] happens every two or three months, which comes with new features,internal API changes, and more. A typical release can contain about 13,000changesets with changes to several hundred thousand lines of code. Recentreleases, along with their dates, can be found atWikipedia.

[1]

Strictly speaking, the Linux kernel does not use semantic versioningnumber scheme, but rather the 9.x pair identifies major releaseversion as a whole number. For each release, x is incremented,but 9 is incremented only if x is deemed large enough (e.g.Linux 5.0 is released following Linux 4.20).

A relatively straightforward discipline is followed with regard to themerging of patches for each release. At the beginning of each developmentcycle, the “merge window” is said to be open. At that time, code which isdeemed to be sufficiently stable (and which is accepted by the developmentcommunity) is merged into the mainline kernel. The bulk of changes for anew development cycle (and all of the major changes) will be merged duringthis time, at a rate approaching 1,000 changes (“patches,” or “changesets”)per day.

(As an aside, it is worth noting that the changes integrated during themerge window do not come out of thin air; they have been collected, tested,and staged ahead of time. How that process works will be described indetail later on).

The merge window lasts for approximately two weeks. At the end of thistime, Linus Torvalds will declare that the window is closed and release thefirst of the “rc” kernels. For the kernel which is destined to be 9.x,for example, the release which happens at the end of the merge window willbe called 9.x-rc1. The -rc1 release is the signal that the time tomerge new features has passed, and that the time to stabilize the nextkernel has begun.

Over the next six to ten weeks, only patches which fix problems should besubmitted to the mainline. On occasion a more significant change will beallowed, but such occasions are rare; developers who try to merge newfeatures outside of the merge window tend to get an unfriendly reception.As a general rule, if you miss the merge window for a given feature, thebest thing to do is to wait for the next development cycle. (An occasionalexception is made for drivers for previously-unsupported hardware; if theytouch no in-tree code, they cannot cause regressions and should be safe toadd at any time).

As fixes make their way into the mainline, the patch rate will slow overtime. Linus releases new -rc kernels about once a week; a normal serieswill get up to somewhere between -rc6 and -rc9 before the kernel isconsidered to be sufficiently stable and the final release is made.At that point the whole process starts over again.

As an example, here is how the 5.4 development cycle went (all dates in2019):

September 15

5.3 stable release

September 30

5.4-rc1, merge window closes

October 6

5.4-rc2

October 13

5.4-rc3

October 20

5.4-rc4

October 27

5.4-rc5

November 3

5.4-rc6

November 10

5.4-rc7

November 17

5.4-rc8

November 24

5.4 stable release

How do the developers decide when to close the development cycle and createthe stable release? The most significant metric used is the list ofregressions from previous releases. No bugs are welcome, but those whichbreak systems which worked in the past are considered to be especiallyserious. For this reason, patches which cause regressions are looked uponunfavorably and are quite likely to be reverted during the stabilizationperiod.

The developers’ goal is to fix all known regressions before the stablerelease is made. In the real world, this kind of perfection is hard toachieve; there are just too many variables in a project of this size.There comes a point where delaying the final release just makes the problemworse; the pile of changes waiting for the next merge window will growlarger, creating even more regressions the next time around. So most kernelsgo out with a handful of known regressions, though, hopefully, none of themare serious.

Once a stable release is made, its ongoing maintenance is passed off to the“stable team,” currently consists of Greg Kroah-Hartman and Sasha Levin. Thestable team will release occasional updates to the stable release using the9.x.y numbering scheme.

To be considered for an update release, a patch must (1) fix a significantbug, and (2) already be merged into the mainline for the next developmentkernel. Kernels will typically receive stable updates for a little morethan one development cycle past their initial release. So, for example, the5.2 kernel’s history looked like this (all dates in 2019):

July 7

5.2 stable release

July 14

5.2.1

July 21

5.2.2

July 26

5.2.3

July 28

5.2.4

July 31

5.2.5

...

...

October 11

5.2.21

5.2.21 was the final stable update of the 5.2 release.

Some kernels are designated “long term” kernels; they will receive supportfor a longer period. Please refer to the following link for the list of activelong term kernel versions and their maintainers:

The selection of a kernel for long-term support is purely a matter of amaintainer having the need and the time to maintain that release. Thereare no known plans for long-term support for any specific upcomingrelease.

2.2.The lifecycle of a patch

Patches do not go directly from the developer’s keyboard into the mainlinekernel. There is, instead, a somewhat involved (if somewhat informal)process designed to ensure that each patch is reviewed for quality and thateach patch implements a change which is desirable to have in the mainline.This process can happen quickly for minor fixes, or, in the case of largeand controversial changes, go on for years. Much developer frustrationcomes from a lack of understanding of this process or from attempts tocircumvent it.

In the hopes of reducing that frustration, this document will describe howa patch gets into the kernel. What follows below is an introduction whichdescribes the process in a somewhat idealized way. A much more detailedtreatment will come in later sections.

The stages that a patch goes through are, generally:

  • Design. This is where the real requirements for the patch - and the waythose requirements will be met - are laid out. Design work is oftendone without involving the community, but it is better to do this workin the open if at all possible; it can save a lot of time redesigningthings later.

  • Early review. Patches are posted to the relevant mailing list, anddevelopers on that list reply with any comments they may have. Thisprocess should turn up any major problems with a patch if all goeswell.

  • Wider review. When the patch is getting close to ready for mainlineinclusion, it should be accepted by a relevant subsystem maintainer -though this acceptance is not a guarantee that the patch will make itall the way to the mainline. The patch will show up in the maintainer’ssubsystem tree and into the -next trees (described below). When theprocess works, this step leads to more extensive review of the patch andthe discovery of any problems resulting from the integration of thispatch with work being done by others.

  • Please note that most maintainers also have day jobs, so mergingyour patch may not be their highest priority. If your patch isgetting feedback about changes that are needed, you should eithermake those changes or justify why they should not be made. If yourpatch has no review complaints but is not being merged by itsappropriate subsystem or driver maintainer, you should be persistentin updating the patch to the current kernel so that it applies cleanlyand keep sending it for review and merging.

  • Merging into the mainline. Eventually, a successful patch will bemerged into the mainline repository managed by Linus Torvalds. Morecomments and/or problems may surface at this time; it is important thatthe developer be responsive to these and fix any issues which arise.

  • Stable release. The number of users potentially affected by the patchis now large, so, once again, new problems may arise.

  • Long-term maintenance. While it is certainly possible for a developerto forget about code after merging it, that sort of behavior tends toleave a poor impression in the development community. Merging codeeliminates some of the maintenance burden, in that others will fixproblems caused by API changes. But the original developer shouldcontinue to take responsibility for the code if it is to remain usefulin the longer term.

One of the largest mistakes made by kernel developers (or their employers)is to try to cut the process down to a single “merging into the mainline”step. This approach invariably leads to frustration for everybodyinvolved.

2.3.How patches get into the Kernel

There is exactly one person who can merge patches into the mainline kernelrepository: Linus Torvalds. But, for example, of the over 9,500 patcheswhich went into the 2.6.38 kernel, only 112 (around 1.3%) were directlychosen by Linus himself. The kernel project has long since grown to a sizewhere no single developer could possibly inspect and select every patchunassisted. The way the kernel developers have addressed this growth isthrough the use of a lieutenant system built around a chain of trust.

The kernel code base is logically broken down into a set of subsystems:networking, specific architecture support, memory management, videodevices, etc. Most subsystems have a designated maintainer, a developerwho has overall responsibility for the code within that subsystem. Thesesubsystem maintainers are the gatekeepers (in a loose way) for the portionof the kernel they manage; they are the ones who will (usually) accept apatch for inclusion into the mainline kernel.

Subsystem maintainers each manage their own version of the kernel sourcetree, usually (but certainly not always) using the git source managementtool. Tools like git (and related tools like quilt or mercurial) allowmaintainers to track a list of patches, including authorship informationand other metadata. At any given time, the maintainer can identify whichpatches in his or her repository are not found in the mainline.

When the merge window opens, top-level maintainers will ask Linus to “pull”the patches they have selected for merging from their repositories. IfLinus agrees, the stream of patches will flow up into his repository,becoming part of the mainline kernel. The amount of attention that Linuspays to specific patches received in a pull operation varies. It is clearthat, sometimes, he looks quite closely. But, as a general rule, Linustrusts the subsystem maintainers to not send bad patches upstream.

Subsystem maintainers, in turn, can pull patches from other maintainers.For example, the networking tree is built from patches which accumulatedfirst in trees dedicated to network device drivers, wireless networking,etc. This chain of repositories can be arbitrarily long, though it rarelyexceeds two or three links. Since each maintainer in the chain truststhose managing lower-level trees, this process is known as the “chain oftrust.”

Clearly, in a system like this, getting patches into the kernel depends onfinding the right maintainer. Sending patches directly to Linus is notnormally the right way to go.

2.4.Next trees

The chain of subsystem trees guides the flow of patches into the kernel,but it also raises an interesting question: what if somebody wants to lookat all of the patches which are being prepared for the next merge window?Developers will be interested in what other changes are pending to seewhether there are any conflicts to worry about; a patch which changes acore kernel function prototype, for example, will conflict with any otherpatches which use the older form of that function. Reviewers and testerswant access to the changes in their integrated form before all of thosechanges land in the mainline kernel. One could pull changes from all ofthe interesting subsystem trees, but that would be a big and error-pronejob.

The answer comes in the form of -next trees, where subsystem trees arecollected for testing and review. The older of these trees, maintained byAndrew Morton, is called “-mm” (for memory management, which is how it gotstarted). The -mm tree integrates patches from a long list of subsystemtrees; it also has some patches aimed at helping with debugging.

Beyond that, -mm contains a significant collection of patches which havebeen selected by Andrew directly. These patches may have been posted on amailing list, or they may apply to a part of the kernel for which there isno designated subsystem tree. As a result, -mm operates as a sort ofsubsystem tree of last resort; if there is no other obvious path for apatch into the mainline, it is likely to end up in -mm. Miscellaneouspatches which accumulate in -mm will eventually either be forwarded on toan appropriate subsystem tree or be sent directly to Linus. In a typicaldevelopment cycle, approximately 5-10% of the patches going into themainline get there via -mm.

The current -mm patch is available in the “mmotm” (-mm of the moment)directory at:

Use of the MMOTM tree is likely to be a frustrating experience, though;there is a definite chance that it will not even compile.

The primary tree for next-cycle patch merging is linux-next, maintained byStephen Rothwell. The linux-next tree is, by design, a snapshot of whatthe mainline is expected to look like after the next merge window closes.Linux-next trees are announced on the linux-kernel and linux-next mailinglists when they are assembled; they can be downloaded from:

Linux-next has become an integral part of the kernel development process;all patches merged during a given merge window should really have foundtheir way into linux-next some time before the merge window opens.

2.5.Staging trees

The kernel source tree contains the drivers/staging/ directory, wheremany sub-directories for drivers or filesystems that are on their way tobeing added to the kernel tree live. They remain in drivers/staging whilethey still need more work; once complete, they can be moved into thekernel proper. This is a way to keep track of drivers that aren’tup to Linux kernel coding or quality standards, but people may want to usethem and track development.

Greg Kroah-Hartman currently maintains the staging tree. Drivers thatstill need work are sent to him, with each driver having its ownsubdirectory in drivers/staging/. Along with the driver source files, aTODO file should be present in the directory as well. The TODO file liststhe pending work that the driver needs for acceptance into the kernelproper, as well as a list of people that should be Cc’d for any patches tothe driver. Current rules require that drivers contributed to stagingmust, at a minimum, compile properly.

Staging can be a relatively easy way to get new drivers into the mainlinewhere, with luck, they will come to the attention of other developers andimprove quickly. Entry into staging is not the end of the story, though;code in staging which is not seeing regular progress will eventually beremoved. Distributors also tend to be relatively reluctant to enablestaging drivers. So staging is, at best, a stop on the way toward becominga proper mainline driver.

2.6.Tools

As can be seen from the above text, the kernel development process dependsheavily on the ability to herd collections of patches in variousdirections. The whole thing would not work anywhere near as well as itdoes without suitably powerful tools. Tutorials on how to use these toolsare well beyond the scope of this document, but there is space for a fewpointers.

By far the dominant source code management system used by the kernelcommunity is git. Git is one of a number of distributed version controlsystems being developed in the free software community. It is well tunedfor kernel development, in that it performs quite well when dealing withlarge repositories and large numbers of patches. It also has a reputationfor being difficult to learn and use, though it has gotten better overtime. Some sort of familiarity with git is almost a requirement for kerneldevelopers; even if they do not use it for their own work, they’ll need gitto keep up with what other developers (and the mainline) are doing.

Git is now packaged by almost all Linux distributions. There is a homepage at:

That page has pointers to documentation and tutorials.

Among the kernel developers who do not use git, the most popular choice isalmost certainly Mercurial:

Mercurial shares many features with git, but it provides an interface whichmany find easier to use.

The other tool worth knowing about is Quilt:

Quilt is a patch management system, rather than a source code managementsystem. It does not track history over time; it is, instead, orientedtoward tracking a specific set of changes against an evolving code base.Some major subsystem maintainers use quilt to manage patches intended to goupstream. For the management of certain kinds of trees (-mm, for example),quilt is the best tool for the job.

2.7.Mailing lists

A great deal of Linux kernel development work is done by way of mailinglists. It is hard to be a fully-functioning member of the communitywithout joining at least one list somewhere. But Linux mailing lists alsorepresent a potential hazard to developers, who risk getting buried under aload of electronic mail, running afoul of the conventions used on the Linuxlists, or both.

Most kernel mailing lists are hosted at kernel.org; the master list canbe found at:

There are lists hosted elsewhere; please check the MAINTAINERS file forthe list relevant for any particular subsystem.

The core mailing list for kernel development is, of course, linux-kernel.This list is an intimidating place to be; volume can reach 500 messages perday, the amount of noise is high, the conversation can be severelytechnical, and participants are not always concerned with showing a highdegree of politeness. But there is no other place where the kerneldevelopment community comes together as a whole; developers who avoid thislist will miss important information.

There are a few hints which can help with linux-kernel survival:

  • Have the list delivered to a separate folder, rather than your mainmailbox. One must be able to ignore the stream for sustained periods oftime.

  • Do not try to follow every conversation - nobody else does. It isimportant to filter on both the topic of interest (though note thatlong-running conversations can drift away from the original subjectwithout changing the email subject line) and the people who areparticipating.

  • Do not feed the trolls. If somebody is trying to stir up an angryresponse, ignore them.

  • When responding to linux-kernel email (or that on other lists) preservethe Cc: header for all involved. In the absence of a strong reason (suchas an explicit request), you should never remove recipients. Always makesure that the person you are responding to is in the Cc: list. Thisconvention also makes it unnecessary to explicitly ask to be copied onreplies to your postings.

  • Search the list archives (and the net as a whole) before askingquestions. Some developers can get impatient with people who clearlyhave not done their homework.

  • Use interleaved (“inline”) replies, which makes your response easier toread. (i.e. avoid top-posting -- the practice of putting your answer abovethe quoted text you are responding to.) For more details, seeDocumentation/process/submitting-patches.rst.

  • Ask on the correct mailing list. Linux-kernel may be the general meetingpoint, but it is not the best place to find developers from allsubsystems.

The last point - finding the correct mailing list - is a common place forbeginning developers to go wrong. Somebody who asks a networking-relatedquestion on linux-kernel will almost certainly receive a polite suggestionto ask on the netdev list instead, as that is the list frequented by mostnetworking developers. Other lists exist for the SCSI, video4linux, IDE,filesystem, etc. subsystems. The best place to look for mailing lists isin the MAINTAINERS file packaged with the kernel source.

2.8.Getting started with Kernel development

Questions about how to get started with the kernel development process arecommon - from both individuals and companies. Equally common are misstepswhich make the beginning of the relationship harder than it has to be.

Companies often look to hire well-known developers to get a developmentgroup started. This can, in fact, be an effective technique. But it alsotends to be expensive and does not do much to grow the pool of experiencedkernel developers. It is possible to bring in-house developers up to speedon Linux kernel development, given the investment of a bit of time. Takingthis time can endow an employer with a group of developers who understandthe kernel and the company both, and who can help to train others as well.Over the medium term, this is often the more profitable approach.

Individual developers are often, understandably, at a loss for a place tostart. Beginning with a large project can be intimidating; one often wantsto test the waters with something smaller first. This is the point wheresome developers jump into the creation of patches fixing spelling errors orminor coding style issues. Unfortunately, such patches create a level ofnoise which is distracting for the development community as a whole, so,increasingly, they are looked down upon. New developers wishing tointroduce themselves to the community will not get the sort of receptionthey wish for by these means.

Andrew Morton gives this advice for aspiring kernel developers

The #1 project for all kernel beginners should surely be "make surethat the kernel runs perfectly at all times on all machines whichyou can lay your hands on".  Usually the way to do this is to workwith others on getting things fixed up (this can requirepersistence!) but that's fine - it's a part of kernel development.

(https://lwn.net/Articles/283982/).

In the absence of obvious problems to fix, developers are advised to lookat the current lists of regressions and open bugs in general. There isnever any shortage of issues in need of fixing; by addressing these issues,developers will gain experience with the process while, at the same time,building respect with the rest of the development community.