2.Process 22 KB

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