1*4882a593Smuzhiyun.. _development_process_intro: 2*4882a593Smuzhiyun 3*4882a593SmuzhiyunIntroduction 4*4882a593Smuzhiyun============ 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunExecutive summary 7*4882a593Smuzhiyun----------------- 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunThe rest of this section covers the scope of the kernel development process 10*4882a593Smuzhiyunand the kinds of frustrations that developers and their employers can 11*4882a593Smuzhiyunencounter there. There are a great many reasons why kernel code should be 12*4882a593Smuzhiyunmerged into the official ("mainline") kernel, including automatic 13*4882a593Smuzhiyunavailability to users, community support in many forms, and the ability to 14*4882a593Smuzhiyuninfluence the direction of kernel development. Code contributed to the 15*4882a593SmuzhiyunLinux kernel must be made available under a GPL-compatible license. 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun:ref:`development_process` introduces the development process, the kernel 18*4882a593Smuzhiyunrelease cycle, and the mechanics of the merge window. The various phases in 19*4882a593Smuzhiyunthe patch development, review, and merging cycle are covered. There is some 20*4882a593Smuzhiyundiscussion of tools and mailing lists. Developers wanting to get started 21*4882a593Smuzhiyunwith kernel development are encouraged to track down and fix bugs as an 22*4882a593Smuzhiyuninitial exercise. 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun:ref:`development_early_stage` covers early-stage project planning, with an 25*4882a593Smuzhiyunemphasis on involving the development community as soon as possible. 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun:ref:`development_coding` is about the coding process; several pitfalls which 28*4882a593Smuzhiyunhave been encountered by other developers are discussed. Some requirements for 29*4882a593Smuzhiyunpatches are covered, and there is an introduction to some of the tools 30*4882a593Smuzhiyunwhich can help to ensure that kernel patches are correct. 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun:ref:`development_posting` talks about the process of posting patches for 33*4882a593Smuzhiyunreview. To be taken seriously by the development community, patches must be 34*4882a593Smuzhiyunproperly formatted and described, and they must be sent to the right place. 35*4882a593SmuzhiyunFollowing the advice in this section should help to ensure the best 36*4882a593Smuzhiyunpossible reception for your work. 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun:ref:`development_followthrough` covers what happens after posting patches; the 39*4882a593Smuzhiyunjob is far from done at that point. Working with reviewers is a crucial part 40*4882a593Smuzhiyunof the development process; this section offers a number of tips on how to 41*4882a593Smuzhiyunavoid problems at this important stage. Developers are cautioned against 42*4882a593Smuzhiyunassuming that the job is done when a patch is merged into the mainline. 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun:ref:`development_advancedtopics` introduces a couple of "advanced" topics: 45*4882a593Smuzhiyunmanaging patches with git and reviewing patches posted by others. 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun:ref:`development_conclusion` concludes the document with pointers to sources 48*4882a593Smuzhiyunfor more information on kernel development. 49*4882a593Smuzhiyun 50*4882a593SmuzhiyunWhat this document is about 51*4882a593Smuzhiyun--------------------------- 52*4882a593Smuzhiyun 53*4882a593SmuzhiyunThe Linux kernel, at over 8 million lines of code and well over 1000 54*4882a593Smuzhiyuncontributors to each release, is one of the largest and most active free 55*4882a593Smuzhiyunsoftware projects in existence. Since its humble beginning in 1991, this 56*4882a593Smuzhiyunkernel has evolved into a best-of-breed operating system component which 57*4882a593Smuzhiyunruns on pocket-sized digital music players, desktop PCs, the largest 58*4882a593Smuzhiyunsupercomputers in existence, and all types of systems in between. It is a 59*4882a593Smuzhiyunrobust, efficient, and scalable solution for almost any situation. 60*4882a593Smuzhiyun 61*4882a593SmuzhiyunWith the growth of Linux has come an increase in the number of developers 62*4882a593Smuzhiyun(and companies) wishing to participate in its development. Hardware 63*4882a593Smuzhiyunvendors want to ensure that Linux supports their products well, making 64*4882a593Smuzhiyunthose products attractive to Linux users. Embedded systems vendors, who 65*4882a593Smuzhiyunuse Linux as a component in an integrated product, want Linux to be as 66*4882a593Smuzhiyuncapable and well-suited to the task at hand as possible. Distributors and 67*4882a593Smuzhiyunother software vendors who base their products on Linux have a clear 68*4882a593Smuzhiyuninterest in the capabilities, performance, and reliability of the Linux 69*4882a593Smuzhiyunkernel. And end users, too, will often wish to change Linux to make it 70*4882a593Smuzhiyunbetter suit their needs. 71*4882a593Smuzhiyun 72*4882a593SmuzhiyunOne of the most compelling features of Linux is that it is accessible to 73*4882a593Smuzhiyunthese developers; anybody with the requisite skills can improve Linux and 74*4882a593Smuzhiyuninfluence the direction of its development. Proprietary products cannot 75*4882a593Smuzhiyunoffer this kind of openness, which is a characteristic of the free software 76*4882a593Smuzhiyunprocess. But, if anything, the kernel is even more open than most other 77*4882a593Smuzhiyunfree software projects. A typical three-month kernel development cycle can 78*4882a593Smuzhiyuninvolve over 1000 developers working for more than 100 different companies 79*4882a593Smuzhiyun(or for no company at all). 80*4882a593Smuzhiyun 81*4882a593SmuzhiyunWorking with the kernel development community is not especially hard. But, 82*4882a593Smuzhiyunthat notwithstanding, many potential contributors have experienced 83*4882a593Smuzhiyundifficulties when trying to do kernel work. The kernel community has 84*4882a593Smuzhiyunevolved its own distinct ways of operating which allow it to function 85*4882a593Smuzhiyunsmoothly (and produce a high-quality product) in an environment where 86*4882a593Smuzhiyunthousands of lines of code are being changed every day. So it is not 87*4882a593Smuzhiyunsurprising that Linux kernel development process differs greatly from 88*4882a593Smuzhiyunproprietary development methods. 89*4882a593Smuzhiyun 90*4882a593SmuzhiyunThe kernel's development process may come across as strange and 91*4882a593Smuzhiyunintimidating to new developers, but there are good reasons and solid 92*4882a593Smuzhiyunexperience behind it. A developer who does not understand the kernel 93*4882a593Smuzhiyuncommunity's ways (or, worse, who tries to flout or circumvent them) will 94*4882a593Smuzhiyunhave a frustrating experience in store. The development community, while 95*4882a593Smuzhiyunbeing helpful to those who are trying to learn, has little time for those 96*4882a593Smuzhiyunwho will not listen or who do not care about the development process. 97*4882a593Smuzhiyun 98*4882a593SmuzhiyunIt is hoped that those who read this document will be able to avoid that 99*4882a593Smuzhiyunfrustrating experience. There is a lot of material here, but the effort 100*4882a593Smuzhiyuninvolved in reading it will be repaid in short order. The development 101*4882a593Smuzhiyuncommunity is always in need of developers who will help to make the kernel 102*4882a593Smuzhiyunbetter; the following text should help you - or those who work for you - 103*4882a593Smuzhiyunjoin our community. 104*4882a593Smuzhiyun 105*4882a593SmuzhiyunCredits 106*4882a593Smuzhiyun------- 107*4882a593Smuzhiyun 108*4882a593SmuzhiyunThis document was written by Jonathan Corbet, corbet@lwn.net. It has been 109*4882a593Smuzhiyunimproved by comments from Johannes Berg, James Berry, Alex Chiang, Roland 110*4882a593SmuzhiyunDreier, Randy Dunlap, Jake Edge, Jiri Kosina, Matt Mackall, Arthur Marsh, 111*4882a593SmuzhiyunAmanda McPherson, Andrew Morton, Andrew Price, Tsugikazu Shibata, and 112*4882a593SmuzhiyunJochen Voß. 113*4882a593Smuzhiyun 114*4882a593SmuzhiyunThis work was supported by the Linux Foundation; thanks especially to 115*4882a593SmuzhiyunAmanda McPherson, who saw the value of this effort and made it all happen. 116*4882a593Smuzhiyun 117*4882a593SmuzhiyunThe importance of getting code into the mainline 118*4882a593Smuzhiyun------------------------------------------------ 119*4882a593Smuzhiyun 120*4882a593SmuzhiyunSome companies and developers occasionally wonder why they should bother 121*4882a593Smuzhiyunlearning how to work with the kernel community and get their code into the 122*4882a593Smuzhiyunmainline kernel (the "mainline" being the kernel maintained by Linus 123*4882a593SmuzhiyunTorvalds and used as a base by Linux distributors). In the short term, 124*4882a593Smuzhiyuncontributing code can look like an avoidable expense; it seems easier to 125*4882a593Smuzhiyunjust keep the code separate and support users directly. The truth of the 126*4882a593Smuzhiyunmatter is that keeping code separate ("out of tree") is a false economy. 127*4882a593Smuzhiyun 128*4882a593SmuzhiyunAs a way of illustrating the costs of out-of-tree code, here are a few 129*4882a593Smuzhiyunrelevant aspects of the kernel development process; most of these will be 130*4882a593Smuzhiyundiscussed in greater detail later in this document. Consider: 131*4882a593Smuzhiyun 132*4882a593Smuzhiyun- Code which has been merged into the mainline kernel is available to all 133*4882a593Smuzhiyun Linux users. It will automatically be present on all distributions which 134*4882a593Smuzhiyun enable it. There is no need for driver disks, downloads, or the hassles 135*4882a593Smuzhiyun of supporting multiple versions of multiple distributions; it all just 136*4882a593Smuzhiyun works, for the developer and for the user. Incorporation into the 137*4882a593Smuzhiyun mainline solves a large number of distribution and support problems. 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun- While kernel developers strive to maintain a stable interface to user 140*4882a593Smuzhiyun space, the internal kernel API is in constant flux. The lack of a stable 141*4882a593Smuzhiyun internal interface is a deliberate design decision; it allows fundamental 142*4882a593Smuzhiyun improvements to be made at any time and results in higher-quality code. 143*4882a593Smuzhiyun But one result of that policy is that any out-of-tree code requires 144*4882a593Smuzhiyun constant upkeep if it is to work with new kernels. Maintaining 145*4882a593Smuzhiyun out-of-tree code requires significant amounts of work just to keep that 146*4882a593Smuzhiyun code working. 147*4882a593Smuzhiyun 148*4882a593Smuzhiyun Code which is in the mainline, instead, does not require this work as the 149*4882a593Smuzhiyun result of a simple rule requiring any developer who makes an API change 150*4882a593Smuzhiyun to also fix any code that breaks as the result of that change. So code 151*4882a593Smuzhiyun which has been merged into the mainline has significantly lower 152*4882a593Smuzhiyun maintenance costs. 153*4882a593Smuzhiyun 154*4882a593Smuzhiyun- Beyond that, code which is in the kernel will often be improved by other 155*4882a593Smuzhiyun developers. Surprising results can come from empowering your user 156*4882a593Smuzhiyun community and customers to improve your product. 157*4882a593Smuzhiyun 158*4882a593Smuzhiyun- Kernel code is subjected to review, both before and after merging into 159*4882a593Smuzhiyun the mainline. No matter how strong the original developer's skills are, 160*4882a593Smuzhiyun this review process invariably finds ways in which the code can be 161*4882a593Smuzhiyun improved. Often review finds severe bugs and security problems. This is 162*4882a593Smuzhiyun especially true for code which has been developed in a closed 163*4882a593Smuzhiyun environment; such code benefits strongly from review by outside 164*4882a593Smuzhiyun developers. Out-of-tree code is lower-quality code. 165*4882a593Smuzhiyun 166*4882a593Smuzhiyun- Participation in the development process is your way to influence the 167*4882a593Smuzhiyun direction of kernel development. Users who complain from the sidelines 168*4882a593Smuzhiyun are heard, but active developers have a stronger voice - and the ability 169*4882a593Smuzhiyun to implement changes which make the kernel work better for their needs. 170*4882a593Smuzhiyun 171*4882a593Smuzhiyun- When code is maintained separately, the possibility that a third party 172*4882a593Smuzhiyun will contribute a different implementation of a similar feature always 173*4882a593Smuzhiyun exists. Should that happen, getting your code merged will become much 174*4882a593Smuzhiyun harder - to the point of impossibility. Then you will be faced with the 175*4882a593Smuzhiyun unpleasant alternatives of either (1) maintaining a nonstandard feature 176*4882a593Smuzhiyun out of tree indefinitely, or (2) abandoning your code and migrating your 177*4882a593Smuzhiyun users over to the in-tree version. 178*4882a593Smuzhiyun 179*4882a593Smuzhiyun- Contribution of code is the fundamental action which makes the whole 180*4882a593Smuzhiyun process work. By contributing your code you can add new functionality to 181*4882a593Smuzhiyun the kernel and provide capabilities and examples which are of use to 182*4882a593Smuzhiyun other kernel developers. If you have developed code for Linux (or are 183*4882a593Smuzhiyun thinking about doing so), you clearly have an interest in the continued 184*4882a593Smuzhiyun success of this platform; contributing code is one of the best ways to 185*4882a593Smuzhiyun help ensure that success. 186*4882a593Smuzhiyun 187*4882a593SmuzhiyunAll of the reasoning above applies to any out-of-tree kernel code, 188*4882a593Smuzhiyunincluding code which is distributed in proprietary, binary-only form. 189*4882a593SmuzhiyunThere are, however, additional factors which should be taken into account 190*4882a593Smuzhiyunbefore considering any sort of binary-only kernel code distribution. These 191*4882a593Smuzhiyuninclude: 192*4882a593Smuzhiyun 193*4882a593Smuzhiyun- The legal issues around the distribution of proprietary kernel modules 194*4882a593Smuzhiyun are cloudy at best; quite a few kernel copyright holders believe that 195*4882a593Smuzhiyun most binary-only modules are derived products of the kernel and that, as 196*4882a593Smuzhiyun a result, their distribution is a violation of the GNU General Public 197*4882a593Smuzhiyun license (about which more will be said below). Your author is not a 198*4882a593Smuzhiyun lawyer, and nothing in this document can possibly be considered to be 199*4882a593Smuzhiyun legal advice. The true legal status of closed-source modules can only be 200*4882a593Smuzhiyun determined by the courts. But the uncertainty which haunts those modules 201*4882a593Smuzhiyun is there regardless. 202*4882a593Smuzhiyun 203*4882a593Smuzhiyun- Binary modules greatly increase the difficulty of debugging kernel 204*4882a593Smuzhiyun problems, to the point that most kernel developers will not even try. So 205*4882a593Smuzhiyun the distribution of binary-only modules will make it harder for your 206*4882a593Smuzhiyun users to get support from the community. 207*4882a593Smuzhiyun 208*4882a593Smuzhiyun- Support is also harder for distributors of binary-only modules, who must 209*4882a593Smuzhiyun provide a version of the module for every distribution and every kernel 210*4882a593Smuzhiyun version they wish to support. Dozens of builds of a single module can 211*4882a593Smuzhiyun be required to provide reasonably comprehensive coverage, and your users 212*4882a593Smuzhiyun will have to upgrade your module separately every time they upgrade their 213*4882a593Smuzhiyun kernel. 214*4882a593Smuzhiyun 215*4882a593Smuzhiyun- Everything that was said above about code review applies doubly to 216*4882a593Smuzhiyun closed-source code. Since this code is not available at all, it cannot 217*4882a593Smuzhiyun have been reviewed by the community and will, beyond doubt, have serious 218*4882a593Smuzhiyun problems. 219*4882a593Smuzhiyun 220*4882a593SmuzhiyunMakers of embedded systems, in particular, may be tempted to disregard much 221*4882a593Smuzhiyunof what has been said in this section in the belief that they are shipping 222*4882a593Smuzhiyuna self-contained product which uses a frozen kernel version and requires no 223*4882a593Smuzhiyunmore development after its release. This argument misses the value of 224*4882a593Smuzhiyunwidespread code review and the value of allowing your users to add 225*4882a593Smuzhiyuncapabilities to your product. But these products, too, have a limited 226*4882a593Smuzhiyuncommercial life, after which a new version must be released. At that 227*4882a593Smuzhiyunpoint, vendors whose code is in the mainline and well maintained will be 228*4882a593Smuzhiyunmuch better positioned to get the new product ready for market quickly. 229*4882a593Smuzhiyun 230*4882a593SmuzhiyunLicensing 231*4882a593Smuzhiyun--------- 232*4882a593Smuzhiyun 233*4882a593SmuzhiyunCode is contributed to the Linux kernel under a number of licenses, but all 234*4882a593Smuzhiyuncode must be compatible with version 2 of the GNU General Public License 235*4882a593Smuzhiyun(GPLv2), which is the license covering the kernel distribution as a whole. 236*4882a593SmuzhiyunIn practice, that means that all code contributions are covered either by 237*4882a593SmuzhiyunGPLv2 (with, optionally, language allowing distribution under later 238*4882a593Smuzhiyunversions of the GPL) or the three-clause BSD license. Any contributions 239*4882a593Smuzhiyunwhich are not covered by a compatible license will not be accepted into the 240*4882a593Smuzhiyunkernel. 241*4882a593Smuzhiyun 242*4882a593SmuzhiyunCopyright assignments are not required (or requested) for code contributed 243*4882a593Smuzhiyunto the kernel. All code merged into the mainline kernel retains its 244*4882a593Smuzhiyunoriginal ownership; as a result, the kernel now has thousands of owners. 245*4882a593Smuzhiyun 246*4882a593SmuzhiyunOne implication of this ownership structure is that any attempt to change 247*4882a593Smuzhiyunthe licensing of the kernel is doomed to almost certain failure. There are 248*4882a593Smuzhiyunfew practical scenarios where the agreement of all copyright holders could 249*4882a593Smuzhiyunbe obtained (or their code removed from the kernel). So, in particular, 250*4882a593Smuzhiyunthere is no prospect of a migration to version 3 of the GPL in the 251*4882a593Smuzhiyunforeseeable future. 252*4882a593Smuzhiyun 253*4882a593SmuzhiyunIt is imperative that all code contributed to the kernel be legitimately 254*4882a593Smuzhiyunfree software. For that reason, code from anonymous (or pseudonymous) 255*4882a593Smuzhiyuncontributors will not be accepted. All contributors are required to "sign 256*4882a593Smuzhiyunoff" on their code, stating that the code can be distributed with the 257*4882a593Smuzhiyunkernel under the GPL. Code which has not been licensed as free software by 258*4882a593Smuzhiyunits owner, or which risks creating copyright-related problems for the 259*4882a593Smuzhiyunkernel (such as code which derives from reverse-engineering efforts lacking 260*4882a593Smuzhiyunproper safeguards) cannot be contributed. 261*4882a593Smuzhiyun 262*4882a593SmuzhiyunQuestions about copyright-related issues are common on Linux development 263*4882a593Smuzhiyunmailing lists. Such questions will normally receive no shortage of 264*4882a593Smuzhiyunanswers, but one should bear in mind that the people answering those 265*4882a593Smuzhiyunquestions are not lawyers and cannot provide legal advice. If you have 266*4882a593Smuzhiyunlegal questions relating to Linux source code, there is no substitute for 267*4882a593Smuzhiyuntalking with a lawyer who understands this field. Relying on answers 268*4882a593Smuzhiyunobtained on technical mailing lists is a risky affair. 269