Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1.. _development_process:
2
3How the development process works
4=================================
5
6Linux kernel development in the early 1990's was a pretty loose affair,
7with relatively small numbers of users and developers involved. With a
8user base in the millions and with some 2,000 developers involved over the
9course of one year, the kernel has since had to evolve a number of
10processes to keep development happening smoothly. A solid understanding of
11how the process works is required in order to be an effective part of it.
12
13The big picture
14---------------
15
16The Linux kernel uses a loosely time-based, rolling release development
17model. A new major kernel release (which we will call, as an example, 9.x)
18[1]_ happens every two or three months, which comes with new features,
19internal API changes, and more. A typical release can contain about 13,000
20changesets with changes to several hundred thousand lines of code. Recent
21releases, along with their dates, can be found at `Wikipedia
22<https://en.wikipedia.org/wiki/Linux_kernel_version_history>`_.
23
24.. [1] Strictly speaking, the Linux kernel does not use semantic versioning
25 number scheme, but rather the 9.x pair identifies major release
26 version as a whole number. For each release, x is incremented,
27 but 9 is incremented only if x is deemed large enough (e.g.
28 Linux 5.0 is released following Linux 4.20).
29
30A relatively straightforward discipline is followed with regard to the
31merging of patches for each release. At the beginning of each development
32cycle, the "merge window" is said to be open. At that time, code which is
33deemed to be sufficiently stable (and which is accepted by the development
34community) is merged into the mainline kernel. The bulk of changes for a
35new development cycle (and all of the major changes) will be merged during
36this time, at a rate approaching 1,000 changes ("patches," or "changesets")
37per day.
38
39(As an aside, it is worth noting that the changes integrated during the
40merge window do not come out of thin air; they have been collected, tested,
41and staged ahead of time. How that process works will be described in
42detail later on).
43
44The merge window lasts for approximately two weeks. At the end of this
45time, Linus Torvalds will declare that the window is closed and release the
46first of the "rc" kernels. For the kernel which is destined to be 9.x,
47for example, the release which happens at the end of the merge window will
48be called 9.x-rc1. The -rc1 release is the signal that the time to
49merge new features has passed, and that the time to stabilize the next
50kernel has begun.
51
52Over the next six to ten weeks, only patches which fix problems should be
53submitted to the mainline. On occasion a more significant change will be
54allowed, but such occasions are rare; developers who try to merge new
55features outside of the merge window tend to get an unfriendly reception.
56As a general rule, if you miss the merge window for a given feature, the
57best thing to do is to wait for the next development cycle. (An occasional
58exception is made for drivers for previously-unsupported hardware; if they
59touch no in-tree code, they cannot cause regressions and should be safe to
60add at any time).
61
62As fixes make their way into the mainline, the patch rate will slow over
63time. Linus releases new -rc kernels about once a week; a normal series
64will get up to somewhere between -rc6 and -rc9 before the kernel is
65considered to be sufficiently stable and the final release is made.
66At that point the whole process starts over again.
67
68As an example, here is how the 5.4 development cycle went (all dates in
692019):
70
71 ============== ===============================
72 September 15 5.3 stable release
73 September 30 5.4-rc1, merge window closes
74 October 6 5.4-rc2
75 October 13 5.4-rc3
76 October 20 5.4-rc4
77 October 27 5.4-rc5
78 November 3 5.4-rc6
79 November 10 5.4-rc7
80 November 17 5.4-rc8
81 November 24 5.4 stable release
82 ============== ===============================
83
84How do the developers decide when to close the development cycle and create
85the stable release? The most significant metric used is the list of
86regressions from previous releases. No bugs are welcome, but those which
87break systems which worked in the past are considered to be especially
88serious. For this reason, patches which cause regressions are looked upon
89unfavorably and are quite likely to be reverted during the stabilization
90period.
91
92The developers' goal is to fix all known regressions before the stable
93release is made. In the real world, this kind of perfection is hard to
94achieve; there are just too many variables in a project of this size.
95There comes a point where delaying the final release just makes the problem
96worse; the pile of changes waiting for the next merge window will grow
97larger, creating even more regressions the next time around. So most kernels
98go out with a handful of known regressions, though, hopefully, none of them
99are serious.
100
101Once a stable release is made, its ongoing maintenance is passed off to the
102"stable team," currently consists of Greg Kroah-Hartman and Sasha Levin. The
103stable team will release occasional updates to the stable release using the
1049.x.y numbering scheme.
105
106To be considered for an update release, a patch must (1) fix a significant
107bug, and (2) already be merged into the mainline for the next development
108kernel. Kernels will typically receive stable updates for a little more
109than one development cycle past their initial release. So, for example, the
1105.2 kernel's history looked like this (all dates in 2019):
111
112 ============== ===============================
113 July 7 5.2 stable release
114 July 14 5.2.1
115 July 21 5.2.2
116 July 26 5.2.3
117 July 28 5.2.4
118 July 31 5.2.5
119 ... ...
120 October 11 5.2.21
121 ============== ===============================
122
1235.2.21 was the final stable update of the 5.2 release.
124
125Some kernels are designated "long term" kernels; they will receive support
126for a longer period. Please refer to the following link for the list of active
127long term kernel versions and their maintainers:
128
129 https://www.kernel.org/category/releases.html
130
131The selection of a kernel for long-term support is purely a matter of a
132maintainer having the need and the time to maintain that release. There
133are no known plans for long-term support for any specific upcoming
134release.
135
136
137The lifecycle of a patch
138------------------------
139
140Patches do not go directly from the developer's keyboard into the mainline
141kernel. There is, instead, a somewhat involved (if somewhat informal)
142process designed to ensure that each patch is reviewed for quality and that
143each patch implements a change which is desirable to have in the mainline.
144This process can happen quickly for minor fixes, or, in the case of large
145and controversial changes, go on for years. Much developer frustration
146comes from a lack of understanding of this process or from attempts to
147circumvent it.
148
149In the hopes of reducing that frustration, this document will describe how
150a patch gets into the kernel. What follows below is an introduction which
151describes the process in a somewhat idealized way. A much more detailed
152treatment will come in later sections.
153
154The stages that a patch goes through are, generally:
155
156 - Design. This is where the real requirements for the patch - and the way
157 those requirements will be met - are laid out. Design work is often
158 done without involving the community, but it is better to do this work
159 in the open if at all possible; it can save a lot of time redesigning
160 things later.
161
162 - Early review. Patches are posted to the relevant mailing list, and
163 developers on that list reply with any comments they may have. This
164 process should turn up any major problems with a patch if all goes
165 well.
166
167 - Wider review. When the patch is getting close to ready for mainline
168 inclusion, it should be accepted by a relevant subsystem maintainer -
169 though this acceptance is not a guarantee that the patch will make it
170 all the way to the mainline. The patch will show up in the maintainer's
171 subsystem tree and into the -next trees (described below). When the
172 process works, this step leads to more extensive review of the patch and
173 the discovery of any problems resulting from the integration of this
174 patch with work being done by others.
175
176- Please note that most maintainers also have day jobs, so merging
177 your patch may not be their highest priority. If your patch is
178 getting feedback about changes that are needed, you should either
179 make those changes or justify why they should not be made. If your
180 patch has no review complaints but is not being merged by its
181 appropriate subsystem or driver maintainer, you should be persistent
182 in updating the patch to the current kernel so that it applies cleanly
183 and keep sending it for review and merging.
184
185 - Merging into the mainline. Eventually, a successful patch will be
186 merged into the mainline repository managed by Linus Torvalds. More
187 comments and/or problems may surface at this time; it is important that
188 the developer be responsive to these and fix any issues which arise.
189
190 - Stable release. The number of users potentially affected by the patch
191 is now large, so, once again, new problems may arise.
192
193 - Long-term maintenance. While it is certainly possible for a developer
194 to forget about code after merging it, that sort of behavior tends to
195 leave a poor impression in the development community. Merging code
196 eliminates some of the maintenance burden, in that others will fix
197 problems caused by API changes. But the original developer should
198 continue to take responsibility for the code if it is to remain useful
199 in the longer term.
200
201One of the largest mistakes made by kernel developers (or their employers)
202is to try to cut the process down to a single "merging into the mainline"
203step. This approach invariably leads to frustration for everybody
204involved.
205
206How patches get into the Kernel
207-------------------------------
208
209There is exactly one person who can merge patches into the mainline kernel
210repository: Linus Torvalds. But, for example, of the over 9,500 patches
211which went into the 2.6.38 kernel, only 112 (around 1.3%) were directly
212chosen by Linus himself. The kernel project has long since grown to a size
213where no single developer could possibly inspect and select every patch
214unassisted. The way the kernel developers have addressed this growth is
215through the use of a lieutenant system built around a chain of trust.
216
217The kernel code base is logically broken down into a set of subsystems:
218networking, specific architecture support, memory management, video
219devices, etc. Most subsystems have a designated maintainer, a developer
220who has overall responsibility for the code within that subsystem. These
221subsystem maintainers are the gatekeepers (in a loose way) for the portion
222of the kernel they manage; they are the ones who will (usually) accept a
223patch for inclusion into the mainline kernel.
224
225Subsystem maintainers each manage their own version of the kernel source
226tree, usually (but certainly not always) using the git source management
227tool. Tools like git (and related tools like quilt or mercurial) allow
228maintainers to track a list of patches, including authorship information
229and other metadata. At any given time, the maintainer can identify which
230patches in his or her repository are not found in the mainline.
231
232When the merge window opens, top-level maintainers will ask Linus to "pull"
233the patches they have selected for merging from their repositories. If
234Linus agrees, the stream of patches will flow up into his repository,
235becoming part of the mainline kernel. The amount of attention that Linus
236pays to specific patches received in a pull operation varies. It is clear
237that, sometimes, he looks quite closely. But, as a general rule, Linus
238trusts the subsystem maintainers to not send bad patches upstream.
239
240Subsystem maintainers, in turn, can pull patches from other maintainers.
241For example, the networking tree is built from patches which accumulated
242first in trees dedicated to network device drivers, wireless networking,
243etc. This chain of repositories can be arbitrarily long, though it rarely
244exceeds two or three links. Since each maintainer in the chain trusts
245those managing lower-level trees, this process is known as the "chain of
246trust."
247
248Clearly, in a system like this, getting patches into the kernel depends on
249finding the right maintainer. Sending patches directly to Linus is not
250normally the right way to go.
251
252
253Next trees
254----------
255
256The chain of subsystem trees guides the flow of patches into the kernel,
257but it also raises an interesting question: what if somebody wants to look
258at all of the patches which are being prepared for the next merge window?
259Developers will be interested in what other changes are pending to see
260whether there are any conflicts to worry about; a patch which changes a
261core kernel function prototype, for example, will conflict with any other
262patches which use the older form of that function. Reviewers and testers
263want access to the changes in their integrated form before all of those
264changes land in the mainline kernel. One could pull changes from all of
265the interesting subsystem trees, but that would be a big and error-prone
266job.
267
268The answer comes in the form of -next trees, where subsystem trees are
269collected for testing and review. The older of these trees, maintained by
270Andrew Morton, is called "-mm" (for memory management, which is how it got
271started). The -mm tree integrates patches from a long list of subsystem
272trees; it also has some patches aimed at helping with debugging.
273
274Beyond that, -mm contains a significant collection of patches which have
275been selected by Andrew directly. These patches may have been posted on a
276mailing list, or they may apply to a part of the kernel for which there is
277no designated subsystem tree. As a result, -mm operates as a sort of
278subsystem tree of last resort; if there is no other obvious path for a
279patch into the mainline, it is likely to end up in -mm. Miscellaneous
280patches which accumulate in -mm will eventually either be forwarded on to
281an appropriate subsystem tree or be sent directly to Linus. In a typical
282development cycle, approximately 5-10% of the patches going into the
283mainline get there via -mm.
284
285The current -mm patch is available in the "mmotm" (-mm of the moment)
286directory at:
287
288 https://www.ozlabs.org/~akpm/mmotm/
289
290Use of the MMOTM tree is likely to be a frustrating experience, though;
291there is a definite chance that it will not even compile.
292
293The primary tree for next-cycle patch merging is linux-next, maintained by
294Stephen Rothwell. The linux-next tree is, by design, a snapshot of what
295the mainline is expected to look like after the next merge window closes.
296Linux-next trees are announced on the linux-kernel and linux-next mailing
297lists when they are assembled; they can be downloaded from:
298
299 https://www.kernel.org/pub/linux/kernel/next/
300
301Linux-next has become an integral part of the kernel development process;
302all patches merged during a given merge window should really have found
303their way into linux-next some time before the merge window opens.
304
305
306Staging trees
307-------------
308
309The kernel source tree contains the drivers/staging/ directory, where
310many sub-directories for drivers or filesystems that are on their way to
311being added to the kernel tree live. They remain in drivers/staging while
312they still need more work; once complete, they can be moved into the
313kernel proper. This is a way to keep track of drivers that aren't
314up to Linux kernel coding or quality standards, but people may want to use
315them and track development.
316
317Greg Kroah-Hartman currently maintains the staging tree. Drivers that
318still need work are sent to him, with each driver having its own
319subdirectory in drivers/staging/. Along with the driver source files, a
320TODO file should be present in the directory as well. The TODO file lists
321the pending work that the driver needs for acceptance into the kernel
322proper, as well as a list of people that should be Cc'd for any patches to
323the driver. Current rules require that drivers contributed to staging
324must, at a minimum, compile properly.
325
326Staging can be a relatively easy way to get new drivers into the mainline
327where, with luck, they will come to the attention of other developers and
328improve quickly. Entry into staging is not the end of the story, though;
329code in staging which is not seeing regular progress will eventually be
330removed. Distributors also tend to be relatively reluctant to enable
331staging drivers. So staging is, at best, a stop on the way toward becoming
332a proper mainline driver.
333
334
335Tools
336-----
337
338As can be seen from the above text, the kernel development process depends
339heavily on the ability to herd collections of patches in various
340directions. The whole thing would not work anywhere near as well as it
341does without suitably powerful tools. Tutorials on how to use these tools
342are well beyond the scope of this document, but there is space for a few
343pointers.
344
345By far the dominant source code management system used by the kernel
346community is git. Git is one of a number of distributed version control
347systems being developed in the free software community. It is well tuned
348for kernel development, in that it performs quite well when dealing with
349large repositories and large numbers of patches. It also has a reputation
350for being difficult to learn and use, though it has gotten better over
351time. Some sort of familiarity with git is almost a requirement for kernel
352developers; even if they do not use it for their own work, they'll need git
353to keep up with what other developers (and the mainline) are doing.
354
355Git is now packaged by almost all Linux distributions. There is a home
356page at:
357
358 https://git-scm.com/
359
360That page has pointers to documentation and tutorials.
361
362Among the kernel developers who do not use git, the most popular choice is
363almost certainly Mercurial:
364
365 https://www.selenic.com/mercurial/
366
367Mercurial shares many features with git, but it provides an interface which
368many find easier to use.
369
370The other tool worth knowing about is Quilt:
371
372 https://savannah.nongnu.org/projects/quilt/
373
374Quilt is a patch management system, rather than a source code management
375system. It does not track history over time; it is, instead, oriented
376toward tracking a specific set of changes against an evolving code base.
377Some major subsystem maintainers use quilt to manage patches intended to go
378upstream. For the management of certain kinds of trees (-mm, for example),
379quilt is the best tool for the job.
380
381
382Mailing lists
383-------------
384
385A great deal of Linux kernel development work is done by way of mailing
386lists. It is hard to be a fully-functioning member of the community
387without joining at least one list somewhere. But Linux mailing lists also
388represent a potential hazard to developers, who risk getting buried under a
389load of electronic mail, running afoul of the conventions used on the Linux
390lists, or both.
391
392Most kernel mailing lists are hosted at kernel.org; the master list can
393be found at:
394
395 https://subspace.kernel.org
396
397There are lists hosted elsewhere; please check the MAINTAINERS file for
398the list relevant for any particular subsystem.
399
400The core mailing list for kernel development is, of course, linux-kernel.
401This list is an intimidating place to be; volume can reach 500 messages per
402day, the amount of noise is high, the conversation can be severely
403technical, and participants are not always concerned with showing a high
404degree of politeness. But there is no other place where the kernel
405development community comes together as a whole; developers who avoid this
406list will miss important information.
407
408There are a few hints which can help with linux-kernel survival:
409
410- Have the list delivered to a separate folder, rather than your main
411 mailbox. One must be able to ignore the stream for sustained periods of
412 time.
413
414- Do not try to follow every conversation - nobody else does. It is
415 important to filter on both the topic of interest (though note that
416 long-running conversations can drift away from the original subject
417 without changing the email subject line) and the people who are
418 participating.
419
420- Do not feed the trolls. If somebody is trying to stir up an angry
421 response, ignore them.
422
423- When responding to linux-kernel email (or that on other lists) preserve
424 the Cc: header for all involved. In the absence of a strong reason (such
425 as an explicit request), you should never remove recipients. Always make
426 sure that the person you are responding to is in the Cc: list. This
427 convention also makes it unnecessary to explicitly ask to be copied on
428 replies to your postings.
429
430- Search the list archives (and the net as a whole) before asking
431 questions. Some developers can get impatient with people who clearly
432 have not done their homework.
433
434- Use interleaved ("inline") replies, which makes your response easier to
435 read. (i.e. avoid top-posting -- the practice of putting your answer above
436 the quoted text you are responding to.) For more details, see
437 :ref:`Documentation/process/submitting-patches.rst <interleaved_replies>`.
438
439- Ask on the correct mailing list. Linux-kernel may be the general meeting
440 point, but it is not the best place to find developers from all
441 subsystems.
442
443The last point - finding the correct mailing list - is a common place for
444beginning developers to go wrong. Somebody who asks a networking-related
445question on linux-kernel will almost certainly receive a polite suggestion
446to ask on the netdev list instead, as that is the list frequented by most
447networking developers. Other lists exist for the SCSI, video4linux, IDE,
448filesystem, etc. subsystems. The best place to look for mailing lists is
449in the MAINTAINERS file packaged with the kernel source.
450
451
452Getting started with Kernel development
453---------------------------------------
454
455Questions about how to get started with the kernel development process are
456common - from both individuals and companies. Equally common are missteps
457which make the beginning of the relationship harder than it has to be.
458
459Companies often look to hire well-known developers to get a development
460group started. This can, in fact, be an effective technique. But it also
461tends to be expensive and does not do much to grow the pool of experienced
462kernel developers. It is possible to bring in-house developers up to speed
463on Linux kernel development, given the investment of a bit of time. Taking
464this time can endow an employer with a group of developers who understand
465the kernel and the company both, and who can help to train others as well.
466Over the medium term, this is often the more profitable approach.
467
468Individual developers are often, understandably, at a loss for a place to
469start. Beginning with a large project can be intimidating; one often wants
470to test the waters with something smaller first. This is the point where
471some developers jump into the creation of patches fixing spelling errors or
472minor coding style issues. Unfortunately, such patches create a level of
473noise which is distracting for the development community as a whole, so,
474increasingly, they are looked down upon. New developers wishing to
475introduce themselves to the community will not get the sort of reception
476they wish for by these means.
477
478Andrew Morton gives this advice for aspiring kernel developers
479
480::
481
482 The #1 project for all kernel beginners should surely be "make sure
483 that the kernel runs perfectly at all times on all machines which
484 you can lay your hands on". Usually the way to do this is to work
485 with others on getting things fixed up (this can require
486 persistence!) but that's fine - it's a part of kernel development.
487
488(https://lwn.net/Articles/283982/).
489
490In the absence of obvious problems to fix, developers are advised to look
491at the current lists of regressions and open bugs in general. There is
492never any shortage of issues in need of fixing; by addressing these issues,
493developers will gain experience with the process while, at the same time,
494building respect with the rest of the development community.