0001 .. _development_process:
0002
0003 How the development process works
0004 =================================
0005
0006 Linux kernel development in the early 1990's was a pretty loose affair,
0007 with relatively small numbers of users and developers involved. With a
0008 user base in the millions and with some 2,000 developers involved over the
0009 course of one year, the kernel has since had to evolve a number of
0010 processes to keep development happening smoothly. A solid understanding of
0011 how the process works is required in order to be an effective part of it.
0012
0013 The big picture
0014 ---------------
0015
0016 The kernel developers use a loosely time-based release process, with a new
0017 major kernel release happening every two or three months. The recent
0018 release history looks like this:
0019
0020 ====== =================
0021 5.0 March 3, 2019
0022 5.1 May 5, 2019
0023 5.2 July 7, 2019
0024 5.3 September 15, 2019
0025 5.4 November 24, 2019
0026 5.5 January 6, 2020
0027 ====== =================
0028
0029 Every 5.x release is a major kernel release with new features, internal
0030 API changes, and more. A typical release can contain about 13,000
0031 changesets with changes to several hundred thousand lines of code. 5.x is
0032 the leading edge of Linux kernel development; the kernel uses a
0033 rolling development model which is continually integrating major changes.
0034
0035 A relatively straightforward discipline is followed with regard to the
0036 merging of patches for each release. At the beginning of each development
0037 cycle, the "merge window" is said to be open. At that time, code which is
0038 deemed to be sufficiently stable (and which is accepted by the development
0039 community) is merged into the mainline kernel. The bulk of changes for a
0040 new development cycle (and all of the major changes) will be merged during
0041 this time, at a rate approaching 1,000 changes ("patches," or "changesets")
0042 per day.
0043
0044 (As an aside, it is worth noting that the changes integrated during the
0045 merge window do not come out of thin air; they have been collected, tested,
0046 and staged ahead of time. How that process works will be described in
0047 detail later on).
0048
0049 The merge window lasts for approximately two weeks. At the end of this
0050 time, Linus Torvalds will declare that the window is closed and release the
0051 first of the "rc" kernels. For the kernel which is destined to be 5.6,
0052 for example, the release which happens at the end of the merge window will
0053 be called 5.6-rc1. The -rc1 release is the signal that the time to
0054 merge new features has passed, and that the time to stabilize the next
0055 kernel has begun.
0056
0057 Over the next six to ten weeks, only patches which fix problems should be
0058 submitted to the mainline. On occasion a more significant change will be
0059 allowed, but such occasions are rare; developers who try to merge new
0060 features outside of the merge window tend to get an unfriendly reception.
0061 As a general rule, if you miss the merge window for a given feature, the
0062 best thing to do is to wait for the next development cycle. (An occasional
0063 exception is made for drivers for previously-unsupported hardware; if they
0064 touch no in-tree code, they cannot cause regressions and should be safe to
0065 add at any time).
0066
0067 As fixes make their way into the mainline, the patch rate will slow over
0068 time. Linus releases new -rc kernels about once a week; a normal series
0069 will get up to somewhere between -rc6 and -rc9 before the kernel is
0070 considered to be sufficiently stable and the final release is made.
0071 At that point the whole process starts over again.
0072
0073 As an example, here is how the 5.4 development cycle went (all dates in
0074 2019):
0075
0076 ============== ===============================
0077 September 15 5.3 stable release
0078 September 30 5.4-rc1, merge window closes
0079 October 6 5.4-rc2
0080 October 13 5.4-rc3
0081 October 20 5.4-rc4
0082 October 27 5.4-rc5
0083 November 3 5.4-rc6
0084 November 10 5.4-rc7
0085 November 17 5.4-rc8
0086 November 24 5.4 stable release
0087 ============== ===============================
0088
0089 How do the developers decide when to close the development cycle and create
0090 the stable release? The most significant metric used is the list of
0091 regressions from previous releases. No bugs are welcome, but those which
0092 break systems which worked in the past are considered to be especially
0093 serious. For this reason, patches which cause regressions are looked upon
0094 unfavorably and are quite likely to be reverted during the stabilization
0095 period.
0096
0097 The developers' goal is to fix all known regressions before the stable
0098 release is made. In the real world, this kind of perfection is hard to
0099 achieve; there are just too many variables in a project of this size.
0100 There comes a point where delaying the final release just makes the problem
0101 worse; the pile of changes waiting for the next merge window will grow
0102 larger, creating even more regressions the next time around. So most 5.x
0103 kernels go out with a handful of known regressions though, hopefully, none
0104 of them are serious.
0105
0106 Once a stable release is made, its ongoing maintenance is passed off to the
0107 "stable team," currently Greg Kroah-Hartman. The stable team will release
0108 occasional updates to the stable release using the 5.x.y numbering scheme.
0109 To be considered for an update release, a patch must (1) fix a significant
0110 bug, and (2) already be merged into the mainline for the next development
0111 kernel. Kernels will typically receive stable updates for a little more
0112 than one development cycle past their initial release. So, for example, the
0113 5.2 kernel's history looked like this (all dates in 2019):
0114
0115 ============== ===============================
0116 July 7 5.2 stable release
0117 July 14 5.2.1
0118 July 21 5.2.2
0119 July 26 5.2.3
0120 July 28 5.2.4
0121 July 31 5.2.5
0122 ... ...
0123 October 11 5.2.21
0124 ============== ===============================
0125
0126 5.2.21 was the final stable update of the 5.2 release.
0127
0128 Some kernels are designated "long term" kernels; they will receive support
0129 for a longer period. As of this writing, the current long term kernels
0130 and their maintainers are:
0131
0132 ====== ================================ =======================
0133 3.16 Ben Hutchings (very long-term kernel)
0134 4.4 Greg Kroah-Hartman & Sasha Levin (very long-term kernel)
0135 4.9 Greg Kroah-Hartman & Sasha Levin
0136 4.14 Greg Kroah-Hartman & Sasha Levin
0137 4.19 Greg Kroah-Hartman & Sasha Levin
0138 5.4 Greg Kroah-Hartman & Sasha Levin
0139 ====== ================================ =======================
0140
0141 The selection of a kernel for long-term support is purely a matter of a
0142 maintainer having the need and the time to maintain that release. There
0143 are no known plans for long-term support for any specific upcoming
0144 release.
0145
0146
0147 The lifecycle of a patch
0148 ------------------------
0149
0150 Patches do not go directly from the developer's keyboard into the mainline
0151 kernel. There is, instead, a somewhat involved (if somewhat informal)
0152 process designed to ensure that each patch is reviewed for quality and that
0153 each patch implements a change which is desirable to have in the mainline.
0154 This process can happen quickly for minor fixes, or, in the case of large
0155 and controversial changes, go on for years. Much developer frustration
0156 comes from a lack of understanding of this process or from attempts to
0157 circumvent it.
0158
0159 In the hopes of reducing that frustration, this document will describe how
0160 a patch gets into the kernel. What follows below is an introduction which
0161 describes the process in a somewhat idealized way. A much more detailed
0162 treatment will come in later sections.
0163
0164 The stages that a patch goes through are, generally:
0165
0166 - Design. This is where the real requirements for the patch - and the way
0167 those requirements will be met - are laid out. Design work is often
0168 done without involving the community, but it is better to do this work
0169 in the open if at all possible; it can save a lot of time redesigning
0170 things later.
0171
0172 - Early review. Patches are posted to the relevant mailing list, and
0173 developers on that list reply with any comments they may have. This
0174 process should turn up any major problems with a patch if all goes
0175 well.
0176
0177 - Wider review. When the patch is getting close to ready for mainline
0178 inclusion, it should be accepted by a relevant subsystem maintainer -
0179 though this acceptance is not a guarantee that the patch will make it
0180 all the way to the mainline. The patch will show up in the maintainer's
0181 subsystem tree and into the -next trees (described below). When the
0182 process works, this step leads to more extensive review of the patch and
0183 the discovery of any problems resulting from the integration of this
0184 patch with work being done by others.
0185
0186 - Please note that most maintainers also have day jobs, so merging
0187 your patch may not be their highest priority. If your patch is
0188 getting feedback about changes that are needed, you should either
0189 make those changes or justify why they should not be made. If your
0190 patch has no review complaints but is not being merged by its
0191 appropriate subsystem or driver maintainer, you should be persistent
0192 in updating the patch to the current kernel so that it applies cleanly
0193 and keep sending it for review and merging.
0194
0195 - Merging into the mainline. Eventually, a successful patch will be
0196 merged into the mainline repository managed by Linus Torvalds. More
0197 comments and/or problems may surface at this time; it is important that
0198 the developer be responsive to these and fix any issues which arise.
0199
0200 - Stable release. The number of users potentially affected by the patch
0201 is now large, so, once again, new problems may arise.
0202
0203 - Long-term maintenance. While it is certainly possible for a developer
0204 to forget about code after merging it, that sort of behavior tends to
0205 leave a poor impression in the development community. Merging code
0206 eliminates some of the maintenance burden, in that others will fix
0207 problems caused by API changes. But the original developer should
0208 continue to take responsibility for the code if it is to remain useful
0209 in the longer term.
0210
0211 One of the largest mistakes made by kernel developers (or their employers)
0212 is to try to cut the process down to a single "merging into the mainline"
0213 step. This approach invariably leads to frustration for everybody
0214 involved.
0215
0216 How patches get into the Kernel
0217 -------------------------------
0218
0219 There is exactly one person who can merge patches into the mainline kernel
0220 repository: Linus Torvalds. But, for example, of the over 9,500 patches
0221 which went into the 2.6.38 kernel, only 112 (around 1.3%) were directly
0222 chosen by Linus himself. The kernel project has long since grown to a size
0223 where no single developer could possibly inspect and select every patch
0224 unassisted. The way the kernel developers have addressed this growth is
0225 through the use of a lieutenant system built around a chain of trust.
0226
0227 The kernel code base is logically broken down into a set of subsystems:
0228 networking, specific architecture support, memory management, video
0229 devices, etc. Most subsystems have a designated maintainer, a developer
0230 who has overall responsibility for the code within that subsystem. These
0231 subsystem maintainers are the gatekeepers (in a loose way) for the portion
0232 of the kernel they manage; they are the ones who will (usually) accept a
0233 patch for inclusion into the mainline kernel.
0234
0235 Subsystem maintainers each manage their own version of the kernel source
0236 tree, usually (but certainly not always) using the git source management
0237 tool. Tools like git (and related tools like quilt or mercurial) allow
0238 maintainers to track a list of patches, including authorship information
0239 and other metadata. At any given time, the maintainer can identify which
0240 patches in his or her repository are not found in the mainline.
0241
0242 When the merge window opens, top-level maintainers will ask Linus to "pull"
0243 the patches they have selected for merging from their repositories. If
0244 Linus agrees, the stream of patches will flow up into his repository,
0245 becoming part of the mainline kernel. The amount of attention that Linus
0246 pays to specific patches received in a pull operation varies. It is clear
0247 that, sometimes, he looks quite closely. But, as a general rule, Linus
0248 trusts the subsystem maintainers to not send bad patches upstream.
0249
0250 Subsystem maintainers, in turn, can pull patches from other maintainers.
0251 For example, the networking tree is built from patches which accumulated
0252 first in trees dedicated to network device drivers, wireless networking,
0253 etc. This chain of repositories can be arbitrarily long, though it rarely
0254 exceeds two or three links. Since each maintainer in the chain trusts
0255 those managing lower-level trees, this process is known as the "chain of
0256 trust."
0257
0258 Clearly, in a system like this, getting patches into the kernel depends on
0259 finding the right maintainer. Sending patches directly to Linus is not
0260 normally the right way to go.
0261
0262
0263 Next trees
0264 ----------
0265
0266 The chain of subsystem trees guides the flow of patches into the kernel,
0267 but it also raises an interesting question: what if somebody wants to look
0268 at all of the patches which are being prepared for the next merge window?
0269 Developers will be interested in what other changes are pending to see
0270 whether there are any conflicts to worry about; a patch which changes a
0271 core kernel function prototype, for example, will conflict with any other
0272 patches which use the older form of that function. Reviewers and testers
0273 want access to the changes in their integrated form before all of those
0274 changes land in the mainline kernel. One could pull changes from all of
0275 the interesting subsystem trees, but that would be a big and error-prone
0276 job.
0277
0278 The answer comes in the form of -next trees, where subsystem trees are
0279 collected for testing and review. The older of these trees, maintained by
0280 Andrew Morton, is called "-mm" (for memory management, which is how it got
0281 started). The -mm tree integrates patches from a long list of subsystem
0282 trees; it also has some patches aimed at helping with debugging.
0283
0284 Beyond that, -mm contains a significant collection of patches which have
0285 been selected by Andrew directly. These patches may have been posted on a
0286 mailing list, or they may apply to a part of the kernel for which there is
0287 no designated subsystem tree. As a result, -mm operates as a sort of
0288 subsystem tree of last resort; if there is no other obvious path for a
0289 patch into the mainline, it is likely to end up in -mm. Miscellaneous
0290 patches which accumulate in -mm will eventually either be forwarded on to
0291 an appropriate subsystem tree or be sent directly to Linus. In a typical
0292 development cycle, approximately 5-10% of the patches going into the
0293 mainline get there via -mm.
0294
0295 The current -mm patch is available in the "mmotm" (-mm of the moment)
0296 directory at:
0297
0298 https://www.ozlabs.org/~akpm/mmotm/
0299
0300 Use of the MMOTM tree is likely to be a frustrating experience, though;
0301 there is a definite chance that it will not even compile.
0302
0303 The primary tree for next-cycle patch merging is linux-next, maintained by
0304 Stephen Rothwell. The linux-next tree is, by design, a snapshot of what
0305 the mainline is expected to look like after the next merge window closes.
0306 Linux-next trees are announced on the linux-kernel and linux-next mailing
0307 lists when they are assembled; they can be downloaded from:
0308
0309 https://www.kernel.org/pub/linux/kernel/next/
0310
0311 Linux-next has become an integral part of the kernel development process;
0312 all patches merged during a given merge window should really have found
0313 their way into linux-next some time before the merge window opens.
0314
0315
0316 Staging trees
0317 -------------
0318
0319 The kernel source tree contains the drivers/staging/ directory, where
0320 many sub-directories for drivers or filesystems that are on their way to
0321 being added to the kernel tree live. They remain in drivers/staging while
0322 they still need more work; once complete, they can be moved into the
0323 kernel proper. This is a way to keep track of drivers that aren't
0324 up to Linux kernel coding or quality standards, but people may want to use
0325 them and track development.
0326
0327 Greg Kroah-Hartman currently maintains the staging tree. Drivers that
0328 still need work are sent to him, with each driver having its own
0329 subdirectory in drivers/staging/. Along with the driver source files, a
0330 TODO file should be present in the directory as well. The TODO file lists
0331 the pending work that the driver needs for acceptance into the kernel
0332 proper, as well as a list of people that should be Cc'd for any patches to
0333 the driver. Current rules require that drivers contributed to staging
0334 must, at a minimum, compile properly.
0335
0336 Staging can be a relatively easy way to get new drivers into the mainline
0337 where, with luck, they will come to the attention of other developers and
0338 improve quickly. Entry into staging is not the end of the story, though;
0339 code in staging which is not seeing regular progress will eventually be
0340 removed. Distributors also tend to be relatively reluctant to enable
0341 staging drivers. So staging is, at best, a stop on the way toward becoming
0342 a proper mainline driver.
0343
0344
0345 Tools
0346 -----
0347
0348 As can be seen from the above text, the kernel development process depends
0349 heavily on the ability to herd collections of patches in various
0350 directions. The whole thing would not work anywhere near as well as it
0351 does without suitably powerful tools. Tutorials on how to use these tools
0352 are well beyond the scope of this document, but there is space for a few
0353 pointers.
0354
0355 By far the dominant source code management system used by the kernel
0356 community is git. Git is one of a number of distributed version control
0357 systems being developed in the free software community. It is well tuned
0358 for kernel development, in that it performs quite well when dealing with
0359 large repositories and large numbers of patches. It also has a reputation
0360 for being difficult to learn and use, though it has gotten better over
0361 time. Some sort of familiarity with git is almost a requirement for kernel
0362 developers; even if they do not use it for their own work, they'll need git
0363 to keep up with what other developers (and the mainline) are doing.
0364
0365 Git is now packaged by almost all Linux distributions. There is a home
0366 page at:
0367
0368 https://git-scm.com/
0369
0370 That page has pointers to documentation and tutorials.
0371
0372 Among the kernel developers who do not use git, the most popular choice is
0373 almost certainly Mercurial:
0374
0375 https://www.selenic.com/mercurial/
0376
0377 Mercurial shares many features with git, but it provides an interface which
0378 many find easier to use.
0379
0380 The other tool worth knowing about is Quilt:
0381
0382 https://savannah.nongnu.org/projects/quilt/
0383
0384 Quilt is a patch management system, rather than a source code management
0385 system. It does not track history over time; it is, instead, oriented
0386 toward tracking a specific set of changes against an evolving code base.
0387 Some major subsystem maintainers use quilt to manage patches intended to go
0388 upstream. For the management of certain kinds of trees (-mm, for example),
0389 quilt is the best tool for the job.
0390
0391
0392 Mailing lists
0393 -------------
0394
0395 A great deal of Linux kernel development work is done by way of mailing
0396 lists. It is hard to be a fully-functioning member of the community
0397 without joining at least one list somewhere. But Linux mailing lists also
0398 represent a potential hazard to developers, who risk getting buried under a
0399 load of electronic mail, running afoul of the conventions used on the Linux
0400 lists, or both.
0401
0402 Most kernel mailing lists are run on vger.kernel.org; the master list can
0403 be found at:
0404
0405 http://vger.kernel.org/vger-lists.html
0406
0407 There are lists hosted elsewhere, though; a number of them are at
0408 redhat.com/mailman/listinfo.
0409
0410 The core mailing list for kernel development is, of course, linux-kernel.
0411 This list is an intimidating place to be; volume can reach 500 messages per
0412 day, the amount of noise is high, the conversation can be severely
0413 technical, and participants are not always concerned with showing a high
0414 degree of politeness. But there is no other place where the kernel
0415 development community comes together as a whole; developers who avoid this
0416 list will miss important information.
0417
0418 There are a few hints which can help with linux-kernel survival:
0419
0420 - Have the list delivered to a separate folder, rather than your main
0421 mailbox. One must be able to ignore the stream for sustained periods of
0422 time.
0423
0424 - Do not try to follow every conversation - nobody else does. It is
0425 important to filter on both the topic of interest (though note that
0426 long-running conversations can drift away from the original subject
0427 without changing the email subject line) and the people who are
0428 participating.
0429
0430 - Do not feed the trolls. If somebody is trying to stir up an angry
0431 response, ignore them.
0432
0433 - When responding to linux-kernel email (or that on other lists) preserve
0434 the Cc: header for all involved. In the absence of a strong reason (such
0435 as an explicit request), you should never remove recipients. Always make
0436 sure that the person you are responding to is in the Cc: list. This
0437 convention also makes it unnecessary to explicitly ask to be copied on
0438 replies to your postings.
0439
0440 - Search the list archives (and the net as a whole) before asking
0441 questions. Some developers can get impatient with people who clearly
0442 have not done their homework.
0443
0444 - Avoid top-posting (the practice of putting your answer above the quoted
0445 text you are responding to). It makes your response harder to read and
0446 makes a poor impression.
0447
0448 - Ask on the correct mailing list. Linux-kernel may be the general meeting
0449 point, but it is not the best place to find developers from all
0450 subsystems.
0451
0452 The last point - finding the correct mailing list - is a common place for
0453 beginning developers to go wrong. Somebody who asks a networking-related
0454 question on linux-kernel will almost certainly receive a polite suggestion
0455 to ask on the netdev list instead, as that is the list frequented by most
0456 networking developers. Other lists exist for the SCSI, video4linux, IDE,
0457 filesystem, etc. subsystems. The best place to look for mailing lists is
0458 in the MAINTAINERS file packaged with the kernel source.
0459
0460
0461 Getting started with Kernel development
0462 ---------------------------------------
0463
0464 Questions about how to get started with the kernel development process are
0465 common - from both individuals and companies. Equally common are missteps
0466 which make the beginning of the relationship harder than it has to be.
0467
0468 Companies often look to hire well-known developers to get a development
0469 group started. This can, in fact, be an effective technique. But it also
0470 tends to be expensive and does not do much to grow the pool of experienced
0471 kernel developers. It is possible to bring in-house developers up to speed
0472 on Linux kernel development, given the investment of a bit of time. Taking
0473 this time can endow an employer with a group of developers who understand
0474 the kernel and the company both, and who can help to train others as well.
0475 Over the medium term, this is often the more profitable approach.
0476
0477 Individual developers are often, understandably, at a loss for a place to
0478 start. Beginning with a large project can be intimidating; one often wants
0479 to test the waters with something smaller first. This is the point where
0480 some developers jump into the creation of patches fixing spelling errors or
0481 minor coding style issues. Unfortunately, such patches create a level of
0482 noise which is distracting for the development community as a whole, so,
0483 increasingly, they are looked down upon. New developers wishing to
0484 introduce themselves to the community will not get the sort of reception
0485 they wish for by these means.
0486
0487 Andrew Morton gives this advice for aspiring kernel developers
0488
0489 ::
0490
0491 The #1 project for all kernel beginners should surely be "make sure
0492 that the kernel runs perfectly at all times on all machines which
0493 you can lay your hands on". Usually the way to do this is to work
0494 with others on getting things fixed up (this can require
0495 persistence!) but that's fine - it's a part of kernel development.
0496
0497 (https://lwn.net/Articles/283982/).
0498
0499 In the absence of obvious problems to fix, developers are advised to look
0500 at the current lists of regressions and open bugs in general. There is
0501 never any shortage of issues in need of fixing; by addressing these issues,
0502 developers will gain experience with the process while, at the same time,
0503 building respect with the rest of the development community.