10e4f07a6SMauro Carvalho Chehab.. _development_process:
20e4f07a6SMauro Carvalho Chehab
30e4f07a6SMauro Carvalho ChehabHow the development process works
40e4f07a6SMauro Carvalho Chehab=================================
50e4f07a6SMauro Carvalho Chehab
60e4f07a6SMauro Carvalho ChehabLinux kernel development in the early 1990's was a pretty loose affair,
70e4f07a6SMauro Carvalho Chehabwith relatively small numbers of users and developers involved.  With a
80e4f07a6SMauro Carvalho Chehabuser base in the millions and with some 2,000 developers involved over the
90e4f07a6SMauro Carvalho Chehabcourse of one year, the kernel has since had to evolve a number of
100e4f07a6SMauro Carvalho Chehabprocesses to keep development happening smoothly.  A solid understanding of
110e4f07a6SMauro Carvalho Chehabhow the process works is required in order to be an effective part of it.
120e4f07a6SMauro Carvalho Chehab
130e4f07a6SMauro Carvalho ChehabThe big picture
140e4f07a6SMauro Carvalho Chehab---------------
150e4f07a6SMauro Carvalho Chehab
160e4f07a6SMauro Carvalho ChehabThe kernel developers use a loosely time-based release process, with a new
170e4f07a6SMauro Carvalho Chehabmajor kernel release happening every two or three months.  The recent
180e4f07a6SMauro Carvalho Chehabrelease history looks like this:
190e4f07a6SMauro Carvalho Chehab
200e4f07a6SMauro Carvalho Chehab	======  =================
21fb0e0ffeSTony Fischetti	5.0	March 3, 2019
22fb0e0ffeSTony Fischetti	5.1	May 5, 2019
23fb0e0ffeSTony Fischetti	5.2	July 7, 2019
24fb0e0ffeSTony Fischetti	5.3	September 15, 2019
25fb0e0ffeSTony Fischetti	5.4	November 24, 2019
26fb0e0ffeSTony Fischetti	5.5	January 6, 2020
270e4f07a6SMauro Carvalho Chehab	======  =================
280e4f07a6SMauro Carvalho Chehab
29fb0e0ffeSTony FischettiEvery 5.x release is a major kernel release with new features, internal
30fb0e0ffeSTony FischettiAPI changes, and more.  A typical release can contain about 13,000
31fb0e0ffeSTony Fischettichangesets with changes to several hundred thousand lines of code.  5.x is
32fb0e0ffeSTony Fischettithe leading edge of Linux kernel development; the kernel uses a
330e4f07a6SMauro Carvalho Chehabrolling development model which is continually integrating major changes.
340e4f07a6SMauro Carvalho Chehab
350e4f07a6SMauro Carvalho ChehabA relatively straightforward discipline is followed with regard to the
360e4f07a6SMauro Carvalho Chehabmerging of patches for each release.  At the beginning of each development
370e4f07a6SMauro Carvalho Chehabcycle, the "merge window" is said to be open.  At that time, code which is
380e4f07a6SMauro Carvalho Chehabdeemed to be sufficiently stable (and which is accepted by the development
390e4f07a6SMauro Carvalho Chehabcommunity) is merged into the mainline kernel.  The bulk of changes for a
400e4f07a6SMauro Carvalho Chehabnew development cycle (and all of the major changes) will be merged during
410e4f07a6SMauro Carvalho Chehabthis time, at a rate approaching 1,000 changes ("patches," or "changesets")
420e4f07a6SMauro Carvalho Chehabper day.
430e4f07a6SMauro Carvalho Chehab
440e4f07a6SMauro Carvalho Chehab(As an aside, it is worth noting that the changes integrated during the
450e4f07a6SMauro Carvalho Chehabmerge window do not come out of thin air; they have been collected, tested,
460e4f07a6SMauro Carvalho Chehaband staged ahead of time.  How that process works will be described in
470e4f07a6SMauro Carvalho Chehabdetail later on).
480e4f07a6SMauro Carvalho Chehab
490e4f07a6SMauro Carvalho ChehabThe merge window lasts for approximately two weeks.  At the end of this
500e4f07a6SMauro Carvalho Chehabtime, Linus Torvalds will declare that the window is closed and release the
51fb0e0ffeSTony Fischettifirst of the "rc" kernels.  For the kernel which is destined to be 5.6,
520e4f07a6SMauro Carvalho Chehabfor example, the release which happens at the end of the merge window will
53fb0e0ffeSTony Fischettibe called 5.6-rc1.  The -rc1 release is the signal that the time to
540e4f07a6SMauro Carvalho Chehabmerge new features has passed, and that the time to stabilize the next
550e4f07a6SMauro Carvalho Chehabkernel has begun.
560e4f07a6SMauro Carvalho Chehab
570e4f07a6SMauro Carvalho ChehabOver the next six to ten weeks, only patches which fix problems should be
580e4f07a6SMauro Carvalho Chehabsubmitted to the mainline.  On occasion a more significant change will be
590e4f07a6SMauro Carvalho Chehaballowed, but such occasions are rare; developers who try to merge new
600e4f07a6SMauro Carvalho Chehabfeatures outside of the merge window tend to get an unfriendly reception.
610e4f07a6SMauro Carvalho ChehabAs a general rule, if you miss the merge window for a given feature, the
620e4f07a6SMauro Carvalho Chehabbest thing to do is to wait for the next development cycle.  (An occasional
630e4f07a6SMauro Carvalho Chehabexception is made for drivers for previously-unsupported hardware; if they
640e4f07a6SMauro Carvalho Chehabtouch no in-tree code, they cannot cause regressions and should be safe to
650e4f07a6SMauro Carvalho Chehabadd at any time).
660e4f07a6SMauro Carvalho Chehab
670e4f07a6SMauro Carvalho ChehabAs fixes make their way into the mainline, the patch rate will slow over
680e4f07a6SMauro Carvalho Chehabtime.  Linus releases new -rc kernels about once a week; a normal series
690e4f07a6SMauro Carvalho Chehabwill get up to somewhere between -rc6 and -rc9 before the kernel is
70fb0e0ffeSTony Fischetticonsidered to be sufficiently stable and the final release is made.
710e4f07a6SMauro Carvalho ChehabAt that point the whole process starts over again.
720e4f07a6SMauro Carvalho Chehab
73fb0e0ffeSTony FischettiAs an example, here is how the 5.4 development cycle went (all dates in
74fb0e0ffeSTony Fischetti2019):
750e4f07a6SMauro Carvalho Chehab
760e4f07a6SMauro Carvalho Chehab	==============  ===============================
77fb0e0ffeSTony Fischetti	September 15	5.3 stable release
78fb0e0ffeSTony Fischetti	September 30	5.4-rc1, merge window closes
79fb0e0ffeSTony Fischetti	October 6	5.4-rc2
80fb0e0ffeSTony Fischetti	October 13	5.4-rc3
81fb0e0ffeSTony Fischetti	October 20	5.4-rc4
82fb0e0ffeSTony Fischetti	October 27	5.4-rc5
83fb0e0ffeSTony Fischetti	November 3	5.4-rc6
84fb0e0ffeSTony Fischetti	November 10	5.4-rc7
85fb0e0ffeSTony Fischetti	November 17	5.4-rc8
86fb0e0ffeSTony Fischetti	November 24	5.4 stable release
870e4f07a6SMauro Carvalho Chehab	==============  ===============================
880e4f07a6SMauro Carvalho Chehab
890e4f07a6SMauro Carvalho ChehabHow do the developers decide when to close the development cycle and create
900e4f07a6SMauro Carvalho Chehabthe stable release?  The most significant metric used is the list of
910e4f07a6SMauro Carvalho Chehabregressions from previous releases.  No bugs are welcome, but those which
920e4f07a6SMauro Carvalho Chehabbreak systems which worked in the past are considered to be especially
930e4f07a6SMauro Carvalho Chehabserious.  For this reason, patches which cause regressions are looked upon
940e4f07a6SMauro Carvalho Chehabunfavorably and are quite likely to be reverted during the stabilization
950e4f07a6SMauro Carvalho Chehabperiod.
960e4f07a6SMauro Carvalho Chehab
970e4f07a6SMauro Carvalho ChehabThe developers' goal is to fix all known regressions before the stable
980e4f07a6SMauro Carvalho Chehabrelease is made.  In the real world, this kind of perfection is hard to
990e4f07a6SMauro Carvalho Chehabachieve; there are just too many variables in a project of this size.
1000e4f07a6SMauro Carvalho ChehabThere comes a point where delaying the final release just makes the problem
1010e4f07a6SMauro Carvalho Chehabworse; the pile of changes waiting for the next merge window will grow
102fb0e0ffeSTony Fischettilarger, creating even more regressions the next time around.  So most 5.x
1030e4f07a6SMauro Carvalho Chehabkernels go out with a handful of known regressions though, hopefully, none
1040e4f07a6SMauro Carvalho Chehabof them are serious.
1050e4f07a6SMauro Carvalho Chehab
1060e4f07a6SMauro Carvalho ChehabOnce a stable release is made, its ongoing maintenance is passed off to the
107fb0e0ffeSTony Fischetti"stable team," currently Greg Kroah-Hartman. The stable team will release
108fb0e0ffeSTony Fischettioccasional updates to the stable release using the 5.x.y numbering scheme.
109fb0e0ffeSTony FischettiTo be considered for an update release, a patch must (1) fix a significant
110fb0e0ffeSTony Fischettibug, and (2) already be merged into the mainline for the next development
111fb0e0ffeSTony Fischettikernel. Kernels will typically receive stable updates for a little more
112fb0e0ffeSTony Fischettithan one development cycle past their initial release. So, for example, the
113fb0e0ffeSTony Fischetti5.2 kernel's history looked like this (all dates in 2019):
1140e4f07a6SMauro Carvalho Chehab
1150e4f07a6SMauro Carvalho Chehab	==============  ===============================
116cca73e49SBilly Wilson	July 7		5.2 stable release
117fb0e0ffeSTony Fischetti	July 14		5.2.1
118fb0e0ffeSTony Fischetti	July 21		5.2.2
119fb0e0ffeSTony Fischetti	July 26		5.2.3
120fb0e0ffeSTony Fischetti	July 28		5.2.4
121fb0e0ffeSTony Fischetti	July 31  	5.2.5
1228962e40cSTim Bird	...		...
123fb0e0ffeSTony Fischetti	October 11	5.2.21
1240e4f07a6SMauro Carvalho Chehab	==============  ===============================
1250e4f07a6SMauro Carvalho Chehab
126fb0e0ffeSTony Fischetti5.2.21 was the final stable update of the 5.2 release.
1270e4f07a6SMauro Carvalho Chehab
1280e4f07a6SMauro Carvalho ChehabSome kernels are designated "long term" kernels; they will receive support
129ea522496SNick Desaulniersfor a longer period.  Please refer to the following link for the list of active
130ea522496SNick Desaulnierslong term kernel versions and their maintainers:
1310e4f07a6SMauro Carvalho Chehab
132ea522496SNick Desaulniers	https://www.kernel.org/category/releases.html
1330e4f07a6SMauro Carvalho Chehab
1340e4f07a6SMauro Carvalho ChehabThe selection of a kernel for long-term support is purely a matter of a
1350e4f07a6SMauro Carvalho Chehabmaintainer having the need and the time to maintain that release.  There
1360e4f07a6SMauro Carvalho Chehabare no known plans for long-term support for any specific upcoming
1370e4f07a6SMauro Carvalho Chehabrelease.
1380e4f07a6SMauro Carvalho Chehab
1390e4f07a6SMauro Carvalho Chehab
1400e4f07a6SMauro Carvalho ChehabThe lifecycle of a patch
1410e4f07a6SMauro Carvalho Chehab------------------------
1420e4f07a6SMauro Carvalho Chehab
1430e4f07a6SMauro Carvalho ChehabPatches do not go directly from the developer's keyboard into the mainline
1440e4f07a6SMauro Carvalho Chehabkernel.  There is, instead, a somewhat involved (if somewhat informal)
1450e4f07a6SMauro Carvalho Chehabprocess designed to ensure that each patch is reviewed for quality and that
1460e4f07a6SMauro Carvalho Chehabeach patch implements a change which is desirable to have in the mainline.
1470e4f07a6SMauro Carvalho ChehabThis process can happen quickly for minor fixes, or, in the case of large
1480e4f07a6SMauro Carvalho Chehaband controversial changes, go on for years.  Much developer frustration
1490e4f07a6SMauro Carvalho Chehabcomes from a lack of understanding of this process or from attempts to
1500e4f07a6SMauro Carvalho Chehabcircumvent it.
1510e4f07a6SMauro Carvalho Chehab
1520e4f07a6SMauro Carvalho ChehabIn the hopes of reducing that frustration, this document will describe how
1530e4f07a6SMauro Carvalho Chehaba patch gets into the kernel.  What follows below is an introduction which
1540e4f07a6SMauro Carvalho Chehabdescribes the process in a somewhat idealized way.  A much more detailed
1550e4f07a6SMauro Carvalho Chehabtreatment will come in later sections.
1560e4f07a6SMauro Carvalho Chehab
1570e4f07a6SMauro Carvalho ChehabThe stages that a patch goes through are, generally:
1580e4f07a6SMauro Carvalho Chehab
1590e4f07a6SMauro Carvalho Chehab - Design.  This is where the real requirements for the patch - and the way
1600e4f07a6SMauro Carvalho Chehab   those requirements will be met - are laid out.  Design work is often
1610e4f07a6SMauro Carvalho Chehab   done without involving the community, but it is better to do this work
1620e4f07a6SMauro Carvalho Chehab   in the open if at all possible; it can save a lot of time redesigning
1630e4f07a6SMauro Carvalho Chehab   things later.
1640e4f07a6SMauro Carvalho Chehab
1650e4f07a6SMauro Carvalho Chehab - Early review.  Patches are posted to the relevant mailing list, and
1660e4f07a6SMauro Carvalho Chehab   developers on that list reply with any comments they may have.  This
1670e4f07a6SMauro Carvalho Chehab   process should turn up any major problems with a patch if all goes
1680e4f07a6SMauro Carvalho Chehab   well.
1690e4f07a6SMauro Carvalho Chehab
1700e4f07a6SMauro Carvalho Chehab - Wider review.  When the patch is getting close to ready for mainline
1710e4f07a6SMauro Carvalho Chehab   inclusion, it should be accepted by a relevant subsystem maintainer -
1720e4f07a6SMauro Carvalho Chehab   though this acceptance is not a guarantee that the patch will make it
1730e4f07a6SMauro Carvalho Chehab   all the way to the mainline.  The patch will show up in the maintainer's
1740e4f07a6SMauro Carvalho Chehab   subsystem tree and into the -next trees (described below).  When the
1750e4f07a6SMauro Carvalho Chehab   process works, this step leads to more extensive review of the patch and
1760e4f07a6SMauro Carvalho Chehab   the discovery of any problems resulting from the integration of this
1770e4f07a6SMauro Carvalho Chehab   patch with work being done by others.
1780e4f07a6SMauro Carvalho Chehab
1790e4f07a6SMauro Carvalho Chehab-  Please note that most maintainers also have day jobs, so merging
1800e4f07a6SMauro Carvalho Chehab   your patch may not be their highest priority.  If your patch is
1810e4f07a6SMauro Carvalho Chehab   getting feedback about changes that are needed, you should either
1820e4f07a6SMauro Carvalho Chehab   make those changes or justify why they should not be made.  If your
1830e4f07a6SMauro Carvalho Chehab   patch has no review complaints but is not being merged by its
1840e4f07a6SMauro Carvalho Chehab   appropriate subsystem or driver maintainer, you should be persistent
1850e4f07a6SMauro Carvalho Chehab   in updating the patch to the current kernel so that it applies cleanly
1860e4f07a6SMauro Carvalho Chehab   and keep sending it for review and merging.
1870e4f07a6SMauro Carvalho Chehab
1880e4f07a6SMauro Carvalho Chehab - Merging into the mainline.  Eventually, a successful patch will be
1890e4f07a6SMauro Carvalho Chehab   merged into the mainline repository managed by Linus Torvalds.  More
1900e4f07a6SMauro Carvalho Chehab   comments and/or problems may surface at this time; it is important that
1910e4f07a6SMauro Carvalho Chehab   the developer be responsive to these and fix any issues which arise.
1920e4f07a6SMauro Carvalho Chehab
1930e4f07a6SMauro Carvalho Chehab - Stable release.  The number of users potentially affected by the patch
1940e4f07a6SMauro Carvalho Chehab   is now large, so, once again, new problems may arise.
1950e4f07a6SMauro Carvalho Chehab
1960e4f07a6SMauro Carvalho Chehab - Long-term maintenance.  While it is certainly possible for a developer
1970e4f07a6SMauro Carvalho Chehab   to forget about code after merging it, that sort of behavior tends to
1980e4f07a6SMauro Carvalho Chehab   leave a poor impression in the development community.  Merging code
1990e4f07a6SMauro Carvalho Chehab   eliminates some of the maintenance burden, in that others will fix
2000e4f07a6SMauro Carvalho Chehab   problems caused by API changes.  But the original developer should
2010e4f07a6SMauro Carvalho Chehab   continue to take responsibility for the code if it is to remain useful
2020e4f07a6SMauro Carvalho Chehab   in the longer term.
2030e4f07a6SMauro Carvalho Chehab
2040e4f07a6SMauro Carvalho ChehabOne of the largest mistakes made by kernel developers (or their employers)
2050e4f07a6SMauro Carvalho Chehabis to try to cut the process down to a single "merging into the mainline"
2060e4f07a6SMauro Carvalho Chehabstep.  This approach invariably leads to frustration for everybody
2070e4f07a6SMauro Carvalho Chehabinvolved.
2080e4f07a6SMauro Carvalho Chehab
2090e4f07a6SMauro Carvalho ChehabHow patches get into the Kernel
2100e4f07a6SMauro Carvalho Chehab-------------------------------
2110e4f07a6SMauro Carvalho Chehab
2120e4f07a6SMauro Carvalho ChehabThere is exactly one person who can merge patches into the mainline kernel
213fb0e0ffeSTony Fischettirepository: Linus Torvalds. But, for example, of the over 9,500 patches
214fb0e0ffeSTony Fischettiwhich went into the 2.6.38 kernel, only 112 (around 1.3%) were directly
215fb0e0ffeSTony Fischettichosen by Linus himself. The kernel project has long since grown to a size
216fb0e0ffeSTony Fischettiwhere no single developer could possibly inspect and select every patch
217fb0e0ffeSTony Fischettiunassisted. The way the kernel developers have addressed this growth is
218fb0e0ffeSTony Fischettithrough the use of a lieutenant system built around a chain of trust.
2190e4f07a6SMauro Carvalho Chehab
2200e4f07a6SMauro Carvalho ChehabThe kernel code base is logically broken down into a set of subsystems:
2210e4f07a6SMauro Carvalho Chehabnetworking, specific architecture support, memory management, video
2220e4f07a6SMauro Carvalho Chehabdevices, etc.  Most subsystems have a designated maintainer, a developer
2230e4f07a6SMauro Carvalho Chehabwho has overall responsibility for the code within that subsystem.  These
2240e4f07a6SMauro Carvalho Chehabsubsystem maintainers are the gatekeepers (in a loose way) for the portion
2250e4f07a6SMauro Carvalho Chehabof the kernel they manage; they are the ones who will (usually) accept a
2260e4f07a6SMauro Carvalho Chehabpatch for inclusion into the mainline kernel.
2270e4f07a6SMauro Carvalho Chehab
2280e4f07a6SMauro Carvalho ChehabSubsystem maintainers each manage their own version of the kernel source
2290e4f07a6SMauro Carvalho Chehabtree, usually (but certainly not always) using the git source management
2300e4f07a6SMauro Carvalho Chehabtool.  Tools like git (and related tools like quilt or mercurial) allow
2310e4f07a6SMauro Carvalho Chehabmaintainers to track a list of patches, including authorship information
2320e4f07a6SMauro Carvalho Chehaband other metadata.  At any given time, the maintainer can identify which
2330e4f07a6SMauro Carvalho Chehabpatches in his or her repository are not found in the mainline.
2340e4f07a6SMauro Carvalho Chehab
2350e4f07a6SMauro Carvalho ChehabWhen the merge window opens, top-level maintainers will ask Linus to "pull"
2360e4f07a6SMauro Carvalho Chehabthe patches they have selected for merging from their repositories.  If
2370e4f07a6SMauro Carvalho ChehabLinus agrees, the stream of patches will flow up into his repository,
2380e4f07a6SMauro Carvalho Chehabbecoming part of the mainline kernel.  The amount of attention that Linus
2390e4f07a6SMauro Carvalho Chehabpays to specific patches received in a pull operation varies.  It is clear
2400e4f07a6SMauro Carvalho Chehabthat, sometimes, he looks quite closely.  But, as a general rule, Linus
2410e4f07a6SMauro Carvalho Chehabtrusts the subsystem maintainers to not send bad patches upstream.
2420e4f07a6SMauro Carvalho Chehab
2430e4f07a6SMauro Carvalho ChehabSubsystem maintainers, in turn, can pull patches from other maintainers.
2440e4f07a6SMauro Carvalho ChehabFor example, the networking tree is built from patches which accumulated
2450e4f07a6SMauro Carvalho Chehabfirst in trees dedicated to network device drivers, wireless networking,
2460e4f07a6SMauro Carvalho Chehabetc.  This chain of repositories can be arbitrarily long, though it rarely
2470e4f07a6SMauro Carvalho Chehabexceeds two or three links.  Since each maintainer in the chain trusts
2480e4f07a6SMauro Carvalho Chehabthose managing lower-level trees, this process is known as the "chain of
2490e4f07a6SMauro Carvalho Chehabtrust."
2500e4f07a6SMauro Carvalho Chehab
2510e4f07a6SMauro Carvalho ChehabClearly, in a system like this, getting patches into the kernel depends on
2520e4f07a6SMauro Carvalho Chehabfinding the right maintainer.  Sending patches directly to Linus is not
2530e4f07a6SMauro Carvalho Chehabnormally the right way to go.
2540e4f07a6SMauro Carvalho Chehab
2550e4f07a6SMauro Carvalho Chehab
2560e4f07a6SMauro Carvalho ChehabNext trees
2570e4f07a6SMauro Carvalho Chehab----------
2580e4f07a6SMauro Carvalho Chehab
2590e4f07a6SMauro Carvalho ChehabThe chain of subsystem trees guides the flow of patches into the kernel,
2600e4f07a6SMauro Carvalho Chehabbut it also raises an interesting question: what if somebody wants to look
2610e4f07a6SMauro Carvalho Chehabat all of the patches which are being prepared for the next merge window?
2620e4f07a6SMauro Carvalho ChehabDevelopers will be interested in what other changes are pending to see
2630e4f07a6SMauro Carvalho Chehabwhether there are any conflicts to worry about; a patch which changes a
2640e4f07a6SMauro Carvalho Chehabcore kernel function prototype, for example, will conflict with any other
2650e4f07a6SMauro Carvalho Chehabpatches which use the older form of that function.  Reviewers and testers
2660e4f07a6SMauro Carvalho Chehabwant access to the changes in their integrated form before all of those
2670e4f07a6SMauro Carvalho Chehabchanges land in the mainline kernel.  One could pull changes from all of
2680e4f07a6SMauro Carvalho Chehabthe interesting subsystem trees, but that would be a big and error-prone
2690e4f07a6SMauro Carvalho Chehabjob.
2700e4f07a6SMauro Carvalho Chehab
2710e4f07a6SMauro Carvalho ChehabThe answer comes in the form of -next trees, where subsystem trees are
2720e4f07a6SMauro Carvalho Chehabcollected for testing and review.  The older of these trees, maintained by
2730e4f07a6SMauro Carvalho ChehabAndrew Morton, is called "-mm" (for memory management, which is how it got
2740e4f07a6SMauro Carvalho Chehabstarted).  The -mm tree integrates patches from a long list of subsystem
2750e4f07a6SMauro Carvalho Chehabtrees; it also has some patches aimed at helping with debugging.
2760e4f07a6SMauro Carvalho Chehab
2770e4f07a6SMauro Carvalho ChehabBeyond that, -mm contains a significant collection of patches which have
2780e4f07a6SMauro Carvalho Chehabbeen selected by Andrew directly.  These patches may have been posted on a
2790e4f07a6SMauro Carvalho Chehabmailing list, or they may apply to a part of the kernel for which there is
2800e4f07a6SMauro Carvalho Chehabno designated subsystem tree.  As a result, -mm operates as a sort of
2810e4f07a6SMauro Carvalho Chehabsubsystem tree of last resort; if there is no other obvious path for a
2820e4f07a6SMauro Carvalho Chehabpatch into the mainline, it is likely to end up in -mm.  Miscellaneous
2830e4f07a6SMauro Carvalho Chehabpatches which accumulate in -mm will eventually either be forwarded on to
2840e4f07a6SMauro Carvalho Chehaban appropriate subsystem tree or be sent directly to Linus.  In a typical
2850e4f07a6SMauro Carvalho Chehabdevelopment cycle, approximately 5-10% of the patches going into the
2860e4f07a6SMauro Carvalho Chehabmainline get there via -mm.
2870e4f07a6SMauro Carvalho Chehab
2880e4f07a6SMauro Carvalho ChehabThe current -mm patch is available in the "mmotm" (-mm of the moment)
2890e4f07a6SMauro Carvalho Chehabdirectory at:
2900e4f07a6SMauro Carvalho Chehab
291e7b4311eSAlexander A. Klimov	https://www.ozlabs.org/~akpm/mmotm/
2920e4f07a6SMauro Carvalho Chehab
2930e4f07a6SMauro Carvalho ChehabUse of the MMOTM tree is likely to be a frustrating experience, though;
2940e4f07a6SMauro Carvalho Chehabthere is a definite chance that it will not even compile.
2950e4f07a6SMauro Carvalho Chehab
2960e4f07a6SMauro Carvalho ChehabThe primary tree for next-cycle patch merging is linux-next, maintained by
2970e4f07a6SMauro Carvalho ChehabStephen Rothwell.  The linux-next tree is, by design, a snapshot of what
2980e4f07a6SMauro Carvalho Chehabthe mainline is expected to look like after the next merge window closes.
2990e4f07a6SMauro Carvalho ChehabLinux-next trees are announced on the linux-kernel and linux-next mailing
3000e4f07a6SMauro Carvalho Chehablists when they are assembled; they can be downloaded from:
3010e4f07a6SMauro Carvalho Chehab
302e7b4311eSAlexander A. Klimov	https://www.kernel.org/pub/linux/kernel/next/
3030e4f07a6SMauro Carvalho Chehab
3040e4f07a6SMauro Carvalho ChehabLinux-next has become an integral part of the kernel development process;
3050e4f07a6SMauro Carvalho Chehaball patches merged during a given merge window should really have found
3060e4f07a6SMauro Carvalho Chehabtheir way into linux-next some time before the merge window opens.
3070e4f07a6SMauro Carvalho Chehab
3080e4f07a6SMauro Carvalho Chehab
3090e4f07a6SMauro Carvalho ChehabStaging trees
3100e4f07a6SMauro Carvalho Chehab-------------
3110e4f07a6SMauro Carvalho Chehab
3120e4f07a6SMauro Carvalho ChehabThe kernel source tree contains the drivers/staging/ directory, where
3130e4f07a6SMauro Carvalho Chehabmany sub-directories for drivers or filesystems that are on their way to
3140e4f07a6SMauro Carvalho Chehabbeing added to the kernel tree live.  They remain in drivers/staging while
3150e4f07a6SMauro Carvalho Chehabthey still need more work; once complete, they can be moved into the
3160e4f07a6SMauro Carvalho Chehabkernel proper.  This is a way to keep track of drivers that aren't
3170e4f07a6SMauro Carvalho Chehabup to Linux kernel coding or quality standards, but people may want to use
3180e4f07a6SMauro Carvalho Chehabthem and track development.
3190e4f07a6SMauro Carvalho Chehab
3200e4f07a6SMauro Carvalho ChehabGreg Kroah-Hartman currently maintains the staging tree.  Drivers that
3210e4f07a6SMauro Carvalho Chehabstill need work are sent to him, with each driver having its own
3220e4f07a6SMauro Carvalho Chehabsubdirectory in drivers/staging/.  Along with the driver source files, a
3230e4f07a6SMauro Carvalho ChehabTODO file should be present in the directory as well.  The TODO file lists
3240e4f07a6SMauro Carvalho Chehabthe pending work that the driver needs for acceptance into the kernel
3250e4f07a6SMauro Carvalho Chehabproper, as well as a list of people that should be Cc'd for any patches to
3260e4f07a6SMauro Carvalho Chehabthe driver.  Current rules require that drivers contributed to staging
3270e4f07a6SMauro Carvalho Chehabmust, at a minimum, compile properly.
3280e4f07a6SMauro Carvalho Chehab
3290e4f07a6SMauro Carvalho ChehabStaging can be a relatively easy way to get new drivers into the mainline
3300e4f07a6SMauro Carvalho Chehabwhere, with luck, they will come to the attention of other developers and
3310e4f07a6SMauro Carvalho Chehabimprove quickly.  Entry into staging is not the end of the story, though;
3320e4f07a6SMauro Carvalho Chehabcode in staging which is not seeing regular progress will eventually be
3330e4f07a6SMauro Carvalho Chehabremoved.  Distributors also tend to be relatively reluctant to enable
3340e4f07a6SMauro Carvalho Chehabstaging drivers.  So staging is, at best, a stop on the way toward becoming
3350e4f07a6SMauro Carvalho Chehaba proper mainline driver.
3360e4f07a6SMauro Carvalho Chehab
3370e4f07a6SMauro Carvalho Chehab
3380e4f07a6SMauro Carvalho ChehabTools
3390e4f07a6SMauro Carvalho Chehab-----
3400e4f07a6SMauro Carvalho Chehab
3410e4f07a6SMauro Carvalho ChehabAs can be seen from the above text, the kernel development process depends
3420e4f07a6SMauro Carvalho Chehabheavily on the ability to herd collections of patches in various
3430e4f07a6SMauro Carvalho Chehabdirections.  The whole thing would not work anywhere near as well as it
3440e4f07a6SMauro Carvalho Chehabdoes without suitably powerful tools.  Tutorials on how to use these tools
3450e4f07a6SMauro Carvalho Chehabare well beyond the scope of this document, but there is space for a few
3460e4f07a6SMauro Carvalho Chehabpointers.
3470e4f07a6SMauro Carvalho Chehab
3480e4f07a6SMauro Carvalho ChehabBy far the dominant source code management system used by the kernel
3490e4f07a6SMauro Carvalho Chehabcommunity is git.  Git is one of a number of distributed version control
3500e4f07a6SMauro Carvalho Chehabsystems being developed in the free software community.  It is well tuned
3510e4f07a6SMauro Carvalho Chehabfor kernel development, in that it performs quite well when dealing with
3520e4f07a6SMauro Carvalho Chehablarge repositories and large numbers of patches.  It also has a reputation
3530e4f07a6SMauro Carvalho Chehabfor being difficult to learn and use, though it has gotten better over
3540e4f07a6SMauro Carvalho Chehabtime.  Some sort of familiarity with git is almost a requirement for kernel
3550e4f07a6SMauro Carvalho Chehabdevelopers; even if they do not use it for their own work, they'll need git
3560e4f07a6SMauro Carvalho Chehabto keep up with what other developers (and the mainline) are doing.
3570e4f07a6SMauro Carvalho Chehab
3580e4f07a6SMauro Carvalho ChehabGit is now packaged by almost all Linux distributions.  There is a home
3590e4f07a6SMauro Carvalho Chehabpage at:
3600e4f07a6SMauro Carvalho Chehab
361e7b4311eSAlexander A. Klimov	https://git-scm.com/
3620e4f07a6SMauro Carvalho Chehab
3630e4f07a6SMauro Carvalho ChehabThat page has pointers to documentation and tutorials.
3640e4f07a6SMauro Carvalho Chehab
3650e4f07a6SMauro Carvalho ChehabAmong the kernel developers who do not use git, the most popular choice is
3660e4f07a6SMauro Carvalho Chehabalmost certainly Mercurial:
3670e4f07a6SMauro Carvalho Chehab
368e7b4311eSAlexander A. Klimov	https://www.selenic.com/mercurial/
3690e4f07a6SMauro Carvalho Chehab
3700e4f07a6SMauro Carvalho ChehabMercurial shares many features with git, but it provides an interface which
3710e4f07a6SMauro Carvalho Chehabmany find easier to use.
3720e4f07a6SMauro Carvalho Chehab
3730e4f07a6SMauro Carvalho ChehabThe other tool worth knowing about is Quilt:
3740e4f07a6SMauro Carvalho Chehab
375e7b4311eSAlexander A. Klimov	https://savannah.nongnu.org/projects/quilt/
3760e4f07a6SMauro Carvalho Chehab
3770e4f07a6SMauro Carvalho ChehabQuilt is a patch management system, rather than a source code management
3780e4f07a6SMauro Carvalho Chehabsystem.  It does not track history over time; it is, instead, oriented
3790e4f07a6SMauro Carvalho Chehabtoward tracking a specific set of changes against an evolving code base.
3800e4f07a6SMauro Carvalho ChehabSome major subsystem maintainers use quilt to manage patches intended to go
3810e4f07a6SMauro Carvalho Chehabupstream.  For the management of certain kinds of trees (-mm, for example),
3820e4f07a6SMauro Carvalho Chehabquilt is the best tool for the job.
3830e4f07a6SMauro Carvalho Chehab
3840e4f07a6SMauro Carvalho Chehab
3850e4f07a6SMauro Carvalho ChehabMailing lists
3860e4f07a6SMauro Carvalho Chehab-------------
3870e4f07a6SMauro Carvalho Chehab
3880e4f07a6SMauro Carvalho ChehabA great deal of Linux kernel development work is done by way of mailing
3890e4f07a6SMauro Carvalho Chehablists.  It is hard to be a fully-functioning member of the community
3900e4f07a6SMauro Carvalho Chehabwithout joining at least one list somewhere.  But Linux mailing lists also
3910e4f07a6SMauro Carvalho Chehabrepresent a potential hazard to developers, who risk getting buried under a
3920e4f07a6SMauro Carvalho Chehabload of electronic mail, running afoul of the conventions used on the Linux
3930e4f07a6SMauro Carvalho Chehablists, or both.
3940e4f07a6SMauro Carvalho Chehab
395*413e775eSKonstantin RyabitsevMost kernel mailing lists are hosted at kernel.org; the master list can
3960e4f07a6SMauro Carvalho Chehabbe found at:
3970e4f07a6SMauro Carvalho Chehab
398*413e775eSKonstantin Ryabitsev	https://subspace.kernel.org
3990e4f07a6SMauro Carvalho Chehab
400*413e775eSKonstantin RyabitsevThere are lists hosted elsewhere; please check the MAINTAINERS file for
401*413e775eSKonstantin Ryabitsevthe list relevant for any particular subsystem.
4020e4f07a6SMauro Carvalho Chehab
4030e4f07a6SMauro Carvalho ChehabThe core mailing list for kernel development is, of course, linux-kernel.
4040e4f07a6SMauro Carvalho ChehabThis list is an intimidating place to be; volume can reach 500 messages per
4050e4f07a6SMauro Carvalho Chehabday, the amount of noise is high, the conversation can be severely
4060e4f07a6SMauro Carvalho Chehabtechnical, and participants are not always concerned with showing a high
4070e4f07a6SMauro Carvalho Chehabdegree of politeness.  But there is no other place where the kernel
4080e4f07a6SMauro Carvalho Chehabdevelopment community comes together as a whole; developers who avoid this
4090e4f07a6SMauro Carvalho Chehablist will miss important information.
4100e4f07a6SMauro Carvalho Chehab
4110e4f07a6SMauro Carvalho ChehabThere are a few hints which can help with linux-kernel survival:
4120e4f07a6SMauro Carvalho Chehab
4130e4f07a6SMauro Carvalho Chehab- Have the list delivered to a separate folder, rather than your main
4140e4f07a6SMauro Carvalho Chehab  mailbox.  One must be able to ignore the stream for sustained periods of
4150e4f07a6SMauro Carvalho Chehab  time.
4160e4f07a6SMauro Carvalho Chehab
4170e4f07a6SMauro Carvalho Chehab- Do not try to follow every conversation - nobody else does.  It is
4180e4f07a6SMauro Carvalho Chehab  important to filter on both the topic of interest (though note that
4190e4f07a6SMauro Carvalho Chehab  long-running conversations can drift away from the original subject
4200e4f07a6SMauro Carvalho Chehab  without changing the email subject line) and the people who are
4210e4f07a6SMauro Carvalho Chehab  participating.
4220e4f07a6SMauro Carvalho Chehab
4230e4f07a6SMauro Carvalho Chehab- Do not feed the trolls.  If somebody is trying to stir up an angry
4240e4f07a6SMauro Carvalho Chehab  response, ignore them.
4250e4f07a6SMauro Carvalho Chehab
4260e4f07a6SMauro Carvalho Chehab- When responding to linux-kernel email (or that on other lists) preserve
4270e4f07a6SMauro Carvalho Chehab  the Cc: header for all involved.  In the absence of a strong reason (such
4280e4f07a6SMauro Carvalho Chehab  as an explicit request), you should never remove recipients.  Always make
4290e4f07a6SMauro Carvalho Chehab  sure that the person you are responding to is in the Cc: list.  This
4300e4f07a6SMauro Carvalho Chehab  convention also makes it unnecessary to explicitly ask to be copied on
4310e4f07a6SMauro Carvalho Chehab  replies to your postings.
4320e4f07a6SMauro Carvalho Chehab
4330e4f07a6SMauro Carvalho Chehab- Search the list archives (and the net as a whole) before asking
4340e4f07a6SMauro Carvalho Chehab  questions.  Some developers can get impatient with people who clearly
4350e4f07a6SMauro Carvalho Chehab  have not done their homework.
4360e4f07a6SMauro Carvalho Chehab
437329ac9afSKees Cook- Use interleaved ("inline") replies, which makes your response easier to
438329ac9afSKees Cook  read. (i.e. avoid top-posting -- the practice of putting your answer above
439329ac9afSKees Cook  the quoted text you are responding to.) For more details, see
440a1d2c9b3SJonathan Corbet  :ref:`Documentation/process/submitting-patches.rst <interleaved_replies>`.
4410e4f07a6SMauro Carvalho Chehab
4420e4f07a6SMauro Carvalho Chehab- Ask on the correct mailing list.  Linux-kernel may be the general meeting
4430e4f07a6SMauro Carvalho Chehab  point, but it is not the best place to find developers from all
4440e4f07a6SMauro Carvalho Chehab  subsystems.
4450e4f07a6SMauro Carvalho Chehab
4460e4f07a6SMauro Carvalho ChehabThe last point - finding the correct mailing list - is a common place for
4470e4f07a6SMauro Carvalho Chehabbeginning developers to go wrong.  Somebody who asks a networking-related
4480e4f07a6SMauro Carvalho Chehabquestion on linux-kernel will almost certainly receive a polite suggestion
4490e4f07a6SMauro Carvalho Chehabto ask on the netdev list instead, as that is the list frequented by most
4500e4f07a6SMauro Carvalho Chehabnetworking developers.  Other lists exist for the SCSI, video4linux, IDE,
4510e4f07a6SMauro Carvalho Chehabfilesystem, etc. subsystems.  The best place to look for mailing lists is
4520e4f07a6SMauro Carvalho Chehabin the MAINTAINERS file packaged with the kernel source.
4530e4f07a6SMauro Carvalho Chehab
4540e4f07a6SMauro Carvalho Chehab
4550e4f07a6SMauro Carvalho ChehabGetting started with Kernel development
4560e4f07a6SMauro Carvalho Chehab---------------------------------------
4570e4f07a6SMauro Carvalho Chehab
4580e4f07a6SMauro Carvalho ChehabQuestions about how to get started with the kernel development process are
4590e4f07a6SMauro Carvalho Chehabcommon - from both individuals and companies.  Equally common are missteps
4600e4f07a6SMauro Carvalho Chehabwhich make the beginning of the relationship harder than it has to be.
4610e4f07a6SMauro Carvalho Chehab
4620e4f07a6SMauro Carvalho ChehabCompanies often look to hire well-known developers to get a development
4630e4f07a6SMauro Carvalho Chehabgroup started.  This can, in fact, be an effective technique.  But it also
4640e4f07a6SMauro Carvalho Chehabtends to be expensive and does not do much to grow the pool of experienced
4650e4f07a6SMauro Carvalho Chehabkernel developers.  It is possible to bring in-house developers up to speed
4660e4f07a6SMauro Carvalho Chehabon Linux kernel development, given the investment of a bit of time.  Taking
4670e4f07a6SMauro Carvalho Chehabthis time can endow an employer with a group of developers who understand
4680e4f07a6SMauro Carvalho Chehabthe kernel and the company both, and who can help to train others as well.
4690e4f07a6SMauro Carvalho ChehabOver the medium term, this is often the more profitable approach.
4700e4f07a6SMauro Carvalho Chehab
4710e4f07a6SMauro Carvalho ChehabIndividual developers are often, understandably, at a loss for a place to
4720e4f07a6SMauro Carvalho Chehabstart.  Beginning with a large project can be intimidating; one often wants
4730e4f07a6SMauro Carvalho Chehabto test the waters with something smaller first.  This is the point where
4740e4f07a6SMauro Carvalho Chehabsome developers jump into the creation of patches fixing spelling errors or
4750e4f07a6SMauro Carvalho Chehabminor coding style issues.  Unfortunately, such patches create a level of
4760e4f07a6SMauro Carvalho Chehabnoise which is distracting for the development community as a whole, so,
4770e4f07a6SMauro Carvalho Chehabincreasingly, they are looked down upon.  New developers wishing to
4780e4f07a6SMauro Carvalho Chehabintroduce themselves to the community will not get the sort of reception
4790e4f07a6SMauro Carvalho Chehabthey wish for by these means.
4800e4f07a6SMauro Carvalho Chehab
4810e4f07a6SMauro Carvalho ChehabAndrew Morton gives this advice for aspiring kernel developers
4820e4f07a6SMauro Carvalho Chehab
4830e4f07a6SMauro Carvalho Chehab::
4840e4f07a6SMauro Carvalho Chehab
4850e4f07a6SMauro Carvalho Chehab	The #1 project for all kernel beginners should surely be "make sure
4860e4f07a6SMauro Carvalho Chehab	that the kernel runs perfectly at all times on all machines which
4870e4f07a6SMauro Carvalho Chehab	you can lay your hands on".  Usually the way to do this is to work
4880e4f07a6SMauro Carvalho Chehab	with others on getting things fixed up (this can require
4890e4f07a6SMauro Carvalho Chehab	persistence!) but that's fine - it's a part of kernel development.
4900e4f07a6SMauro Carvalho Chehab
491e7b4311eSAlexander A. Klimov(https://lwn.net/Articles/283982/).
4920e4f07a6SMauro Carvalho Chehab
4930e4f07a6SMauro Carvalho ChehabIn the absence of obvious problems to fix, developers are advised to look
4940e4f07a6SMauro Carvalho Chehabat the current lists of regressions and open bugs in general.  There is
4950e4f07a6SMauro Carvalho Chehabnever any shortage of issues in need of fixing; by addressing these issues,
4960e4f07a6SMauro Carvalho Chehabdevelopers will gain experience with the process while, at the same time,
4970e4f07a6SMauro Carvalho Chehabbuilding respect with the rest of the development community.
498