1.Intro 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. 1: A GUIDE TO THE KERNEL DEVELOPMENT PROCESS
  2. The purpose of this document is to help developers (and their managers)
  3. work with the development community with a minimum of frustration. It is
  4. an attempt to document how this community works in a way which is
  5. accessible to those who are not intimately familiar with Linux kernel
  6. development (or, indeed, free software development in general). While
  7. there is some technical material here, this is very much a process-oriented
  8. discussion which does not require a deep knowledge of kernel programming to
  9. understand.
  10. 1.1: EXECUTIVE SUMMARY
  11. The rest of this section covers the scope of the kernel development process
  12. and the kinds of frustrations that developers and their employers can
  13. encounter there. There are a great many reasons why kernel code should be
  14. merged into the official ("mainline") kernel, including automatic
  15. availability to users, community support in many forms, and the ability to
  16. influence the direction of kernel development. Code contributed to the
  17. Linux kernel must be made available under a GPL-compatible license.
  18. Section 2 introduces the development process, the kernel release cycle, and
  19. the mechanics of the merge window. The various phases in the patch
  20. development, review, and merging cycle are covered. There is some
  21. discussion of tools and mailing lists. Developers wanting to get started
  22. with kernel development are encouraged to track down and fix bugs as an
  23. initial exercise.
  24. Section 3 covers early-stage project planning, with an emphasis on
  25. involving the development community as soon as possible.
  26. Section 4 is about the coding process; several pitfalls which have been
  27. encountered by other developers are discussed. Some requirements for
  28. patches are covered, and there is an introduction to some of the tools
  29. which can help to ensure that kernel patches are correct.
  30. Section 5 talks about the process of posting patches for review. To be
  31. taken seriously by the development community, patches must be properly
  32. formatted and described, and they must be sent to the right place.
  33. Following the advice in this section should help to ensure the best
  34. possible reception for your work.
  35. Section 6 covers what happens after posting patches; the job is far from
  36. done at that point. Working with reviewers is a crucial part of the
  37. development process; this section offers a number of tips on how to avoid
  38. problems at this important stage. Developers are cautioned against
  39. assuming that the job is done when a patch is merged into the mainline.
  40. Section 7 introduces a couple of "advanced" topics: managing patches with
  41. git and reviewing patches posted by others.
  42. Section 8 concludes the document with pointers to sources for more
  43. information on kernel development.
  44. 1.2: WHAT THIS DOCUMENT IS ABOUT
  45. The Linux kernel, at over 8 million lines of code and well over 1000
  46. contributors to each release, is one of the largest and most active free
  47. software projects in existence. Since its humble beginning in 1991, this
  48. kernel has evolved into a best-of-breed operating system component which
  49. runs on pocket-sized digital music players, desktop PCs, the largest
  50. supercomputers in existence, and all types of systems in between. It is a
  51. robust, efficient, and scalable solution for almost any situation.
  52. With the growth of Linux has come an increase in the number of developers
  53. (and companies) wishing to participate in its development. Hardware
  54. vendors want to ensure that Linux supports their products well, making
  55. those products attractive to Linux users. Embedded systems vendors, who
  56. use Linux as a component in an integrated product, want Linux to be as
  57. capable and well-suited to the task at hand as possible. Distributors and
  58. other software vendors who base their products on Linux have a clear
  59. interest in the capabilities, performance, and reliability of the Linux
  60. kernel. And end users, too, will often wish to change Linux to make it
  61. better suit their needs.
  62. One of the most compelling features of Linux is that it is accessible to
  63. these developers; anybody with the requisite skills can improve Linux and
  64. influence the direction of its development. Proprietary products cannot
  65. offer this kind of openness, which is a characteristic of the free software
  66. process. But, if anything, the kernel is even more open than most other
  67. free software projects. A typical three-month kernel development cycle can
  68. involve over 1000 developers working for more than 100 different companies
  69. (or for no company at all).
  70. Working with the kernel development community is not especially hard. But,
  71. that notwithstanding, many potential contributors have experienced
  72. difficulties when trying to do kernel work. The kernel community has
  73. evolved its own distinct ways of operating which allow it to function
  74. smoothly (and produce a high-quality product) in an environment where
  75. thousands of lines of code are being changed every day. So it is not
  76. surprising that Linux kernel development process differs greatly from
  77. proprietary development methods.
  78. The kernel's development process may come across as strange and
  79. intimidating to new developers, but there are good reasons and solid
  80. experience behind it. A developer who does not understand the kernel
  81. community's ways (or, worse, who tries to flout or circumvent them) will
  82. have a frustrating experience in store. The development community, while
  83. being helpful to those who are trying to learn, has little time for those
  84. who will not listen or who do not care about the development process.
  85. It is hoped that those who read this document will be able to avoid that
  86. frustrating experience. There is a lot of material here, but the effort
  87. involved in reading it will be repaid in short order. The development
  88. community is always in need of developers who will help to make the kernel
  89. better; the following text should help you - or those who work for you -
  90. join our community.
  91. 1.3: CREDITS
  92. This document was written by Jonathan Corbet, corbet@lwn.net. It has been
  93. improved by comments from Johannes Berg, James Berry, Alex Chiang, Roland
  94. Dreier, Randy Dunlap, Jake Edge, Jiri Kosina, Matt Mackall, Arthur Marsh,
  95. Amanda McPherson, Andrew Morton, Andrew Price, Tsugikazu Shibata, and
  96. Jochen Voß.
  97. This work was supported by the Linux Foundation; thanks especially to
  98. Amanda McPherson, who saw the value of this effort and made it all happen.
  99. 1.4: THE IMPORTANCE OF GETTING CODE INTO THE MAINLINE
  100. Some companies and developers occasionally wonder why they should bother
  101. learning how to work with the kernel community and get their code into the
  102. mainline kernel (the "mainline" being the kernel maintained by Linus
  103. Torvalds and used as a base by Linux distributors). In the short term,
  104. contributing code can look like an avoidable expense; it seems easier to
  105. just keep the code separate and support users directly. The truth of the
  106. matter is that keeping code separate ("out of tree") is a false economy.
  107. As a way of illustrating the costs of out-of-tree code, here are a few
  108. relevant aspects of the kernel development process; most of these will be
  109. discussed in greater detail later in this document. Consider:
  110. - Code which has been merged into the mainline kernel is available to all
  111. Linux users. It will automatically be present on all distributions which
  112. enable it. There is no need for driver disks, downloads, or the hassles
  113. of supporting multiple versions of multiple distributions; it all just
  114. works, for the developer and for the user. Incorporation into the
  115. mainline solves a large number of distribution and support problems.
  116. - While kernel developers strive to maintain a stable interface to user
  117. space, the internal kernel API is in constant flux. The lack of a stable
  118. internal interface is a deliberate design decision; it allows fundamental
  119. improvements to be made at any time and results in higher-quality code.
  120. But one result of that policy is that any out-of-tree code requires
  121. constant upkeep if it is to work with new kernels. Maintaining
  122. out-of-tree code requires significant amounts of work just to keep that
  123. code working.
  124. Code which is in the mainline, instead, does not require this work as the
  125. result of a simple rule requiring any developer who makes an API change
  126. to also fix any code that breaks as the result of that change. So code
  127. which has been merged into the mainline has significantly lower
  128. maintenance costs.
  129. - Beyond that, code which is in the kernel will often be improved by other
  130. developers. Surprising results can come from empowering your user
  131. community and customers to improve your product.
  132. - Kernel code is subjected to review, both before and after merging into
  133. the mainline. No matter how strong the original developer's skills are,
  134. this review process invariably finds ways in which the code can be
  135. improved. Often review finds severe bugs and security problems. This is
  136. especially true for code which has been developed in a closed
  137. environment; such code benefits strongly from review by outside
  138. developers. Out-of-tree code is lower-quality code.
  139. - Participation in the development process is your way to influence the
  140. direction of kernel development. Users who complain from the sidelines
  141. are heard, but active developers have a stronger voice - and the ability
  142. to implement changes which make the kernel work better for their needs.
  143. - When code is maintained separately, the possibility that a third party
  144. will contribute a different implementation of a similar feature always
  145. exists. Should that happen, getting your code merged will become much
  146. harder - to the point of impossibility. Then you will be faced with the
  147. unpleasant alternatives of either (1) maintaining a nonstandard feature
  148. out of tree indefinitely, or (2) abandoning your code and migrating your
  149. users over to the in-tree version.
  150. - Contribution of code is the fundamental action which makes the whole
  151. process work. By contributing your code you can add new functionality to
  152. the kernel and provide capabilities and examples which are of use to
  153. other kernel developers. If you have developed code for Linux (or are
  154. thinking about doing so), you clearly have an interest in the continued
  155. success of this platform; contributing code is one of the best ways to
  156. help ensure that success.
  157. All of the reasoning above applies to any out-of-tree kernel code,
  158. including code which is distributed in proprietary, binary-only form.
  159. There are, however, additional factors which should be taken into account
  160. before considering any sort of binary-only kernel code distribution. These
  161. include:
  162. - The legal issues around the distribution of proprietary kernel modules
  163. are cloudy at best; quite a few kernel copyright holders believe that
  164. most binary-only modules are derived products of the kernel and that, as
  165. a result, their distribution is a violation of the GNU General Public
  166. license (about which more will be said below). Your author is not a
  167. lawyer, and nothing in this document can possibly be considered to be
  168. legal advice. The true legal status of closed-source modules can only be
  169. determined by the courts. But the uncertainty which haunts those modules
  170. is there regardless.
  171. - Binary modules greatly increase the difficulty of debugging kernel
  172. problems, to the point that most kernel developers will not even try. So
  173. the distribution of binary-only modules will make it harder for your
  174. users to get support from the community.
  175. - Support is also harder for distributors of binary-only modules, who must
  176. provide a version of the module for every distribution and every kernel
  177. version they wish to support. Dozens of builds of a single module can
  178. be required to provide reasonably comprehensive coverage, and your users
  179. will have to upgrade your module separately every time they upgrade their
  180. kernel.
  181. - Everything that was said above about code review applies doubly to
  182. closed-source code. Since this code is not available at all, it cannot
  183. have been reviewed by the community and will, beyond doubt, have serious
  184. problems.
  185. Makers of embedded systems, in particular, may be tempted to disregard much
  186. of what has been said in this section in the belief that they are shipping
  187. a self-contained product which uses a frozen kernel version and requires no
  188. more development after its release. This argument misses the value of
  189. widespread code review and the value of allowing your users to add
  190. capabilities to your product. But these products, too, have a limited
  191. commercial life, after which a new version must be released. At that
  192. point, vendors whose code is in the mainline and well maintained will be
  193. much better positioned to get the new product ready for market quickly.
  194. 1.5: LICENSING
  195. Code is contributed to the Linux kernel under a number of licenses, but all
  196. code must be compatible with version 2 of the GNU General Public License
  197. (GPLv2), which is the license covering the kernel distribution as a whole.
  198. In practice, that means that all code contributions are covered either by
  199. GPLv2 (with, optionally, language allowing distribution under later
  200. versions of the GPL) or the three-clause BSD license. Any contributions
  201. which are not covered by a compatible license will not be accepted into the
  202. kernel.
  203. Copyright assignments are not required (or requested) for code contributed
  204. to the kernel. All code merged into the mainline kernel retains its
  205. original ownership; as a result, the kernel now has thousands of owners.
  206. One implication of this ownership structure is that any attempt to change
  207. the licensing of the kernel is doomed to almost certain failure. There are
  208. few practical scenarios where the agreement of all copyright holders could
  209. be obtained (or their code removed from the kernel). So, in particular,
  210. there is no prospect of a migration to version 3 of the GPL in the
  211. foreseeable future.
  212. It is imperative that all code contributed to the kernel be legitimately
  213. free software. For that reason, code from anonymous (or pseudonymous)
  214. contributors will not be accepted. All contributors are required to "sign
  215. off" on their code, stating that the code can be distributed with the
  216. kernel under the GPL. Code which has not been licensed as free software by
  217. its owner, or which risks creating copyright-related problems for the
  218. kernel (such as code which derives from reverse-engineering efforts lacking
  219. proper safeguards) cannot be contributed.
  220. Questions about copyright-related issues are common on Linux development
  221. mailing lists. Such questions will normally receive no shortage of
  222. answers, but one should bear in mind that the people answering those
  223. questions are not lawyers and cannot provide legal advice. If you have
  224. legal questions relating to Linux source code, there is no substitute for
  225. talking with a lawyer who understands this field. Relying on answers
  226. obtained on technical mailing lists is a risky affair.