2.Process.rst 24 KB

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