1*4882a593Smuzhiyun.. _process_howto: 2*4882a593Smuzhiyun 3*4882a593SmuzhiyunHOWTO do Linux kernel development 4*4882a593Smuzhiyun================================= 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunThis is the be-all, end-all document on this topic. It contains 7*4882a593Smuzhiyuninstructions on how to become a Linux kernel developer and how to learn 8*4882a593Smuzhiyunto work with the Linux kernel development community. It tries to not 9*4882a593Smuzhiyuncontain anything related to the technical aspects of kernel programming, 10*4882a593Smuzhiyunbut will help point you in the right direction for that. 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunIf anything in this document becomes out of date, please send in patches 13*4882a593Smuzhiyunto the maintainer of this file, who is listed at the bottom of the 14*4882a593Smuzhiyundocument. 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun 17*4882a593SmuzhiyunIntroduction 18*4882a593Smuzhiyun------------ 19*4882a593Smuzhiyun 20*4882a593SmuzhiyunSo, you want to learn how to become a Linux kernel developer? Or you 21*4882a593Smuzhiyunhave been told by your manager, "Go write a Linux driver for this 22*4882a593Smuzhiyundevice." This document's goal is to teach you everything you need to 23*4882a593Smuzhiyunknow to achieve this by describing the process you need to go through, 24*4882a593Smuzhiyunand hints on how to work with the community. It will also try to 25*4882a593Smuzhiyunexplain some of the reasons why the community works like it does. 26*4882a593Smuzhiyun 27*4882a593SmuzhiyunThe kernel is written mostly in C, with some architecture-dependent 28*4882a593Smuzhiyunparts written in assembly. A good understanding of C is required for 29*4882a593Smuzhiyunkernel development. Assembly (any architecture) is not required unless 30*4882a593Smuzhiyunyou plan to do low-level development for that architecture. Though they 31*4882a593Smuzhiyunare not a good substitute for a solid C education and/or years of 32*4882a593Smuzhiyunexperience, the following books are good for, if anything, reference: 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun - "The C Programming Language" by Kernighan and Ritchie [Prentice Hall] 35*4882a593Smuzhiyun - "Practical C Programming" by Steve Oualline [O'Reilly] 36*4882a593Smuzhiyun - "C: A Reference Manual" by Harbison and Steele [Prentice Hall] 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunThe kernel is written using GNU C and the GNU toolchain. While it 39*4882a593Smuzhiyunadheres to the ISO C89 standard, it uses a number of extensions that are 40*4882a593Smuzhiyunnot featured in the standard. The kernel is a freestanding C 41*4882a593Smuzhiyunenvironment, with no reliance on the standard C library, so some 42*4882a593Smuzhiyunportions of the C standard are not supported. Arbitrary long long 43*4882a593Smuzhiyundivisions and floating point are not allowed. It can sometimes be 44*4882a593Smuzhiyundifficult to understand the assumptions the kernel has on the toolchain 45*4882a593Smuzhiyunand the extensions that it uses, and unfortunately there is no 46*4882a593Smuzhiyundefinitive reference for them. Please check the gcc info pages (`info 47*4882a593Smuzhiyungcc`) for some information on them. 48*4882a593Smuzhiyun 49*4882a593SmuzhiyunPlease remember that you are trying to learn how to work with the 50*4882a593Smuzhiyunexisting development community. It is a diverse group of people, with 51*4882a593Smuzhiyunhigh standards for coding, style and procedure. These standards have 52*4882a593Smuzhiyunbeen created over time based on what they have found to work best for 53*4882a593Smuzhiyunsuch a large and geographically dispersed team. Try to learn as much as 54*4882a593Smuzhiyunpossible about these standards ahead of time, as they are well 55*4882a593Smuzhiyundocumented; do not expect people to adapt to you or your company's way 56*4882a593Smuzhiyunof doing things. 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun 59*4882a593SmuzhiyunLegal Issues 60*4882a593Smuzhiyun------------ 61*4882a593Smuzhiyun 62*4882a593SmuzhiyunThe Linux kernel source code is released under the GPL. Please see the file 63*4882a593SmuzhiyunCOPYING in the main directory of the source tree. The Linux kernel licensing 64*4882a593Smuzhiyunrules and how to use `SPDX <https://spdx.org/>`_ identifiers in source code are 65*4882a593Smuzhiyundescribed in :ref:`Documentation/process/license-rules.rst <kernel_licensing>`. 66*4882a593SmuzhiyunIf you have further questions about the license, please contact a lawyer, and do 67*4882a593Smuzhiyunnot ask on the Linux kernel mailing list. The people on the mailing lists are 68*4882a593Smuzhiyunnot lawyers, and you should not rely on their statements on legal matters. 69*4882a593Smuzhiyun 70*4882a593SmuzhiyunFor common questions and answers about the GPL, please see: 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun https://www.gnu.org/licenses/gpl-faq.html 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun 75*4882a593SmuzhiyunDocumentation 76*4882a593Smuzhiyun------------- 77*4882a593Smuzhiyun 78*4882a593SmuzhiyunThe Linux kernel source tree has a large range of documents that are 79*4882a593Smuzhiyuninvaluable for learning how to interact with the kernel community. When 80*4882a593Smuzhiyunnew features are added to the kernel, it is recommended that new 81*4882a593Smuzhiyundocumentation files are also added which explain how to use the feature. 82*4882a593SmuzhiyunWhen a kernel change causes the interface that the kernel exposes to 83*4882a593Smuzhiyunuserspace to change, it is recommended that you send the information or 84*4882a593Smuzhiyuna patch to the manual pages explaining the change to the manual pages 85*4882a593Smuzhiyunmaintainer at mtk.manpages@gmail.com, and CC the list 86*4882a593Smuzhiyunlinux-api@vger.kernel.org. 87*4882a593Smuzhiyun 88*4882a593SmuzhiyunHere is a list of files that are in the kernel source tree that are 89*4882a593Smuzhiyunrequired reading: 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun :ref:`Documentation/admin-guide/README.rst <readme>` 92*4882a593Smuzhiyun This file gives a short background on the Linux kernel and describes 93*4882a593Smuzhiyun what is necessary to do to configure and build the kernel. People 94*4882a593Smuzhiyun who are new to the kernel should start here. 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun :ref:`Documentation/process/changes.rst <changes>` 97*4882a593Smuzhiyun This file gives a list of the minimum levels of various software 98*4882a593Smuzhiyun packages that are necessary to build and run the kernel 99*4882a593Smuzhiyun successfully. 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun :ref:`Documentation/process/coding-style.rst <codingstyle>` 102*4882a593Smuzhiyun This describes the Linux kernel coding style, and some of the 103*4882a593Smuzhiyun rationale behind it. All new code is expected to follow the 104*4882a593Smuzhiyun guidelines in this document. Most maintainers will only accept 105*4882a593Smuzhiyun patches if these rules are followed, and many people will only 106*4882a593Smuzhiyun review code if it is in the proper style. 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun :ref:`Documentation/process/submitting-patches.rst <submittingpatches>` and :ref:`Documentation/process/submitting-drivers.rst <submittingdrivers>` 109*4882a593Smuzhiyun These files describe in explicit detail how to successfully create 110*4882a593Smuzhiyun and send a patch, including (but not limited to): 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun - Email contents 113*4882a593Smuzhiyun - Email format 114*4882a593Smuzhiyun - Who to send it to 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun Following these rules will not guarantee success (as all patches are 117*4882a593Smuzhiyun subject to scrutiny for content and style), but not following them 118*4882a593Smuzhiyun will almost always prevent it. 119*4882a593Smuzhiyun 120*4882a593Smuzhiyun Other excellent descriptions of how to create patches properly are: 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun "The Perfect Patch" 123*4882a593Smuzhiyun https://www.ozlabs.org/~akpm/stuff/tpp.txt 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun "Linux kernel patch submission format" 126*4882a593Smuzhiyun https://web.archive.org/web/20180829112450/http://linux.yyz.us/patch-format.html 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun :ref:`Documentation/process/stable-api-nonsense.rst <stable_api_nonsense>` 129*4882a593Smuzhiyun This file describes the rationale behind the conscious decision to 130*4882a593Smuzhiyun not have a stable API within the kernel, including things like: 131*4882a593Smuzhiyun 132*4882a593Smuzhiyun - Subsystem shim-layers (for compatibility?) 133*4882a593Smuzhiyun - Driver portability between Operating Systems. 134*4882a593Smuzhiyun - Mitigating rapid change within the kernel source tree (or 135*4882a593Smuzhiyun preventing rapid change) 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun This document is crucial for understanding the Linux development 138*4882a593Smuzhiyun philosophy and is very important for people moving to Linux from 139*4882a593Smuzhiyun development on other Operating Systems. 140*4882a593Smuzhiyun 141*4882a593Smuzhiyun :ref:`Documentation/admin-guide/security-bugs.rst <securitybugs>` 142*4882a593Smuzhiyun If you feel you have found a security problem in the Linux kernel, 143*4882a593Smuzhiyun please follow the steps in this document to help notify the kernel 144*4882a593Smuzhiyun developers, and help solve the issue. 145*4882a593Smuzhiyun 146*4882a593Smuzhiyun :ref:`Documentation/process/management-style.rst <managementstyle>` 147*4882a593Smuzhiyun This document describes how Linux kernel maintainers operate and the 148*4882a593Smuzhiyun shared ethos behind their methodologies. This is important reading 149*4882a593Smuzhiyun for anyone new to kernel development (or anyone simply curious about 150*4882a593Smuzhiyun it), as it resolves a lot of common misconceptions and confusion 151*4882a593Smuzhiyun about the unique behavior of kernel maintainers. 152*4882a593Smuzhiyun 153*4882a593Smuzhiyun :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>` 154*4882a593Smuzhiyun This file describes the rules on how the stable kernel releases 155*4882a593Smuzhiyun happen, and what to do if you want to get a change into one of these 156*4882a593Smuzhiyun releases. 157*4882a593Smuzhiyun 158*4882a593Smuzhiyun :ref:`Documentation/process/kernel-docs.rst <kernel_docs>` 159*4882a593Smuzhiyun A list of external documentation that pertains to kernel 160*4882a593Smuzhiyun development. Please consult this list if you do not find what you 161*4882a593Smuzhiyun are looking for within the in-kernel documentation. 162*4882a593Smuzhiyun 163*4882a593Smuzhiyun :ref:`Documentation/process/applying-patches.rst <applying_patches>` 164*4882a593Smuzhiyun A good introduction describing exactly what a patch is and how to 165*4882a593Smuzhiyun apply it to the different development branches of the kernel. 166*4882a593Smuzhiyun 167*4882a593SmuzhiyunThe kernel also has a large number of documents that can be 168*4882a593Smuzhiyunautomatically generated from the source code itself or from 169*4882a593SmuzhiyunReStructuredText markups (ReST), like this one. This includes a 170*4882a593Smuzhiyunfull description of the in-kernel API, and rules on how to handle 171*4882a593Smuzhiyunlocking properly. 172*4882a593Smuzhiyun 173*4882a593SmuzhiyunAll such documents can be generated as PDF or HTML by running:: 174*4882a593Smuzhiyun 175*4882a593Smuzhiyun make pdfdocs 176*4882a593Smuzhiyun make htmldocs 177*4882a593Smuzhiyun 178*4882a593Smuzhiyunrespectively from the main kernel source directory. 179*4882a593Smuzhiyun 180*4882a593SmuzhiyunThe documents that uses ReST markup will be generated at Documentation/output. 181*4882a593SmuzhiyunThey can also be generated on LaTeX and ePub formats with:: 182*4882a593Smuzhiyun 183*4882a593Smuzhiyun make latexdocs 184*4882a593Smuzhiyun make epubdocs 185*4882a593Smuzhiyun 186*4882a593SmuzhiyunBecoming A Kernel Developer 187*4882a593Smuzhiyun--------------------------- 188*4882a593Smuzhiyun 189*4882a593SmuzhiyunIf you do not know anything about Linux kernel development, you should 190*4882a593Smuzhiyunlook at the Linux KernelNewbies project: 191*4882a593Smuzhiyun 192*4882a593Smuzhiyun https://kernelnewbies.org 193*4882a593Smuzhiyun 194*4882a593SmuzhiyunIt consists of a helpful mailing list where you can ask almost any type 195*4882a593Smuzhiyunof basic kernel development question (make sure to search the archives 196*4882a593Smuzhiyunfirst, before asking something that has already been answered in the 197*4882a593Smuzhiyunpast.) It also has an IRC channel that you can use to ask questions in 198*4882a593Smuzhiyunreal-time, and a lot of helpful documentation that is useful for 199*4882a593Smuzhiyunlearning about Linux kernel development. 200*4882a593Smuzhiyun 201*4882a593SmuzhiyunThe website has basic information about code organization, subsystems, 202*4882a593Smuzhiyunand current projects (both in-tree and out-of-tree). It also describes 203*4882a593Smuzhiyunsome basic logistical information, like how to compile a kernel and 204*4882a593Smuzhiyunapply a patch. 205*4882a593Smuzhiyun 206*4882a593SmuzhiyunIf you do not know where you want to start, but you want to look for 207*4882a593Smuzhiyunsome task to start doing to join into the kernel development community, 208*4882a593Smuzhiyungo to the Linux Kernel Janitor's project: 209*4882a593Smuzhiyun 210*4882a593Smuzhiyun https://kernelnewbies.org/KernelJanitors 211*4882a593Smuzhiyun 212*4882a593SmuzhiyunIt is a great place to start. It describes a list of relatively simple 213*4882a593Smuzhiyunproblems that need to be cleaned up and fixed within the Linux kernel 214*4882a593Smuzhiyunsource tree. Working with the developers in charge of this project, you 215*4882a593Smuzhiyunwill learn the basics of getting your patch into the Linux kernel tree, 216*4882a593Smuzhiyunand possibly be pointed in the direction of what to go work on next, if 217*4882a593Smuzhiyunyou do not already have an idea. 218*4882a593Smuzhiyun 219*4882a593SmuzhiyunBefore making any actual modifications to the Linux kernel code, it is 220*4882a593Smuzhiyunimperative to understand how the code in question works. For this 221*4882a593Smuzhiyunpurpose, nothing is better than reading through it directly (most tricky 222*4882a593Smuzhiyunbits are commented well), perhaps even with the help of specialized 223*4882a593Smuzhiyuntools. One such tool that is particularly recommended is the Linux 224*4882a593SmuzhiyunCross-Reference project, which is able to present source code in a 225*4882a593Smuzhiyunself-referential, indexed webpage format. An excellent up-to-date 226*4882a593Smuzhiyunrepository of the kernel code may be found at: 227*4882a593Smuzhiyun 228*4882a593Smuzhiyun https://elixir.bootlin.com/ 229*4882a593Smuzhiyun 230*4882a593Smuzhiyun 231*4882a593SmuzhiyunThe development process 232*4882a593Smuzhiyun----------------------- 233*4882a593Smuzhiyun 234*4882a593SmuzhiyunLinux kernel development process currently consists of a few different 235*4882a593Smuzhiyunmain kernel "branches" and lots of different subsystem-specific kernel 236*4882a593Smuzhiyunbranches. These different branches are: 237*4882a593Smuzhiyun 238*4882a593Smuzhiyun - Linus's mainline tree 239*4882a593Smuzhiyun - Various stable trees with multiple major numbers 240*4882a593Smuzhiyun - Subsystem-specific trees 241*4882a593Smuzhiyun - linux-next integration testing tree 242*4882a593Smuzhiyun 243*4882a593SmuzhiyunMainline tree 244*4882a593Smuzhiyun~~~~~~~~~~~~~ 245*4882a593Smuzhiyun 246*4882a593SmuzhiyunThe mainline tree is maintained by Linus Torvalds, and can be found at 247*4882a593Smuzhiyunhttps://kernel.org or in the repo. Its development process is as follows: 248*4882a593Smuzhiyun 249*4882a593Smuzhiyun - As soon as a new kernel is released a two week window is open, 250*4882a593Smuzhiyun during this period of time maintainers can submit big diffs to 251*4882a593Smuzhiyun Linus, usually the patches that have already been included in the 252*4882a593Smuzhiyun linux-next for a few weeks. The preferred way to submit big changes 253*4882a593Smuzhiyun is using git (the kernel's source management tool, more information 254*4882a593Smuzhiyun can be found at https://git-scm.com/) but plain patches are also just 255*4882a593Smuzhiyun fine. 256*4882a593Smuzhiyun - After two weeks a -rc1 kernel is released and the focus is on making the 257*4882a593Smuzhiyun new kernel as rock solid as possible. Most of the patches at this point 258*4882a593Smuzhiyun should fix a regression. Bugs that have always existed are not 259*4882a593Smuzhiyun regressions, so only push these kinds of fixes if they are important. 260*4882a593Smuzhiyun Please note that a whole new driver (or filesystem) might be accepted 261*4882a593Smuzhiyun after -rc1 because there is no risk of causing regressions with such a 262*4882a593Smuzhiyun change as long as the change is self-contained and does not affect areas 263*4882a593Smuzhiyun outside of the code that is being added. git can be used to send 264*4882a593Smuzhiyun patches to Linus after -rc1 is released, but the patches need to also be 265*4882a593Smuzhiyun sent to a public mailing list for review. 266*4882a593Smuzhiyun - A new -rc is released whenever Linus deems the current git tree to 267*4882a593Smuzhiyun be in a reasonably sane state adequate for testing. The goal is to 268*4882a593Smuzhiyun release a new -rc kernel every week. 269*4882a593Smuzhiyun - Process continues until the kernel is considered "ready", the 270*4882a593Smuzhiyun process should last around 6 weeks. 271*4882a593Smuzhiyun 272*4882a593SmuzhiyunIt is worth mentioning what Andrew Morton wrote on the linux-kernel 273*4882a593Smuzhiyunmailing list about kernel releases: 274*4882a593Smuzhiyun 275*4882a593Smuzhiyun *"Nobody knows when a kernel will be released, because it's 276*4882a593Smuzhiyun released according to perceived bug status, not according to a 277*4882a593Smuzhiyun preconceived timeline."* 278*4882a593Smuzhiyun 279*4882a593SmuzhiyunVarious stable trees with multiple major numbers 280*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 281*4882a593Smuzhiyun 282*4882a593SmuzhiyunKernels with 3-part versions are -stable kernels. They contain 283*4882a593Smuzhiyunrelatively small and critical fixes for security problems or significant 284*4882a593Smuzhiyunregressions discovered in a given major mainline release. Each release 285*4882a593Smuzhiyunin a major stable series increments the third part of the version 286*4882a593Smuzhiyunnumber, keeping the first two parts the same. 287*4882a593Smuzhiyun 288*4882a593SmuzhiyunThis is the recommended branch for users who want the most recent stable 289*4882a593Smuzhiyunkernel and are not interested in helping test development/experimental 290*4882a593Smuzhiyunversions. 291*4882a593Smuzhiyun 292*4882a593SmuzhiyunStable trees are maintained by the "stable" team <stable@vger.kernel.org>, and 293*4882a593Smuzhiyunare released as needs dictate. The normal release period is approximately 294*4882a593Smuzhiyuntwo weeks, but it can be longer if there are no pressing problems. A 295*4882a593Smuzhiyunsecurity-related problem, instead, can cause a release to happen almost 296*4882a593Smuzhiyuninstantly. 297*4882a593Smuzhiyun 298*4882a593SmuzhiyunThe file :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>` 299*4882a593Smuzhiyunin the kernel tree documents what kinds of changes are acceptable for 300*4882a593Smuzhiyunthe -stable tree, and how the release process works. 301*4882a593Smuzhiyun 302*4882a593SmuzhiyunSubsystem-specific trees 303*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~ 304*4882a593Smuzhiyun 305*4882a593SmuzhiyunThe maintainers of the various kernel subsystems --- and also many 306*4882a593Smuzhiyunkernel subsystem developers --- expose their current state of 307*4882a593Smuzhiyundevelopment in source repositories. That way, others can see what is 308*4882a593Smuzhiyunhappening in the different areas of the kernel. In areas where 309*4882a593Smuzhiyundevelopment is rapid, a developer may be asked to base his submissions 310*4882a593Smuzhiyunonto such a subsystem kernel tree so that conflicts between the 311*4882a593Smuzhiyunsubmission and other already ongoing work are avoided. 312*4882a593Smuzhiyun 313*4882a593SmuzhiyunMost of these repositories are git trees, but there are also other SCMs 314*4882a593Smuzhiyunin use, or patch queues being published as quilt series. Addresses of 315*4882a593Smuzhiyunthese subsystem repositories are listed in the MAINTAINERS file. Many 316*4882a593Smuzhiyunof them can be browsed at https://git.kernel.org/. 317*4882a593Smuzhiyun 318*4882a593SmuzhiyunBefore a proposed patch is committed to such a subsystem tree, it is 319*4882a593Smuzhiyunsubject to review which primarily happens on mailing lists (see the 320*4882a593Smuzhiyunrespective section below). For several kernel subsystems, this review 321*4882a593Smuzhiyunprocess is tracked with the tool patchwork. Patchwork offers a web 322*4882a593Smuzhiyuninterface which shows patch postings, any comments on a patch or 323*4882a593Smuzhiyunrevisions to it, and maintainers can mark patches as under review, 324*4882a593Smuzhiyunaccepted, or rejected. Most of these patchwork sites are listed at 325*4882a593Smuzhiyunhttps://patchwork.kernel.org/. 326*4882a593Smuzhiyun 327*4882a593Smuzhiyunlinux-next integration testing tree 328*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 329*4882a593Smuzhiyun 330*4882a593SmuzhiyunBefore updates from subsystem trees are merged into the mainline tree, 331*4882a593Smuzhiyunthey need to be integration-tested. For this purpose, a special 332*4882a593Smuzhiyuntesting repository exists into which virtually all subsystem trees are 333*4882a593Smuzhiyunpulled on an almost daily basis: 334*4882a593Smuzhiyun 335*4882a593Smuzhiyun https://git.kernel.org/?p=linux/kernel/git/next/linux-next.git 336*4882a593Smuzhiyun 337*4882a593SmuzhiyunThis way, the linux-next gives a summary outlook onto what will be 338*4882a593Smuzhiyunexpected to go into the mainline kernel at the next merge period. 339*4882a593SmuzhiyunAdventurous testers are very welcome to runtime-test the linux-next. 340*4882a593Smuzhiyun 341*4882a593Smuzhiyun 342*4882a593SmuzhiyunBug Reporting 343*4882a593Smuzhiyun------------- 344*4882a593Smuzhiyun 345*4882a593Smuzhiyunhttps://bugzilla.kernel.org is where the Linux kernel developers track kernel 346*4882a593Smuzhiyunbugs. Users are encouraged to report all bugs that they find in this 347*4882a593Smuzhiyuntool. For details on how to use the kernel bugzilla, please see: 348*4882a593Smuzhiyun 349*4882a593Smuzhiyun https://bugzilla.kernel.org/page.cgi?id=faq.html 350*4882a593Smuzhiyun 351*4882a593SmuzhiyunThe file :ref:`admin-guide/reporting-bugs.rst <reportingbugs>` 352*4882a593Smuzhiyunin the main kernel source directory has a good 353*4882a593Smuzhiyuntemplate for how to report a possible kernel bug, and details what kind 354*4882a593Smuzhiyunof information is needed by the kernel developers to help track down the 355*4882a593Smuzhiyunproblem. 356*4882a593Smuzhiyun 357*4882a593Smuzhiyun 358*4882a593SmuzhiyunManaging bug reports 359*4882a593Smuzhiyun-------------------- 360*4882a593Smuzhiyun 361*4882a593SmuzhiyunOne of the best ways to put into practice your hacking skills is by fixing 362*4882a593Smuzhiyunbugs reported by other people. Not only you will help to make the kernel 363*4882a593Smuzhiyunmore stable, but you'll also learn to fix real world problems and you will 364*4882a593Smuzhiyunimprove your skills, and other developers will be aware of your presence. 365*4882a593SmuzhiyunFixing bugs is one of the best ways to get merits among other developers, 366*4882a593Smuzhiyunbecause not many people like wasting time fixing other people's bugs. 367*4882a593Smuzhiyun 368*4882a593SmuzhiyunTo work in the already reported bug reports, go to https://bugzilla.kernel.org. 369*4882a593Smuzhiyun 370*4882a593Smuzhiyun 371*4882a593SmuzhiyunMailing lists 372*4882a593Smuzhiyun------------- 373*4882a593Smuzhiyun 374*4882a593SmuzhiyunAs some of the above documents describe, the majority of the core kernel 375*4882a593Smuzhiyundevelopers participate on the Linux Kernel Mailing list. Details on how 376*4882a593Smuzhiyunto subscribe and unsubscribe from the list can be found at: 377*4882a593Smuzhiyun 378*4882a593Smuzhiyun http://vger.kernel.org/vger-lists.html#linux-kernel 379*4882a593Smuzhiyun 380*4882a593SmuzhiyunThere are archives of the mailing list on the web in many different 381*4882a593Smuzhiyunplaces. Use a search engine to find these archives. For example: 382*4882a593Smuzhiyun 383*4882a593Smuzhiyun http://dir.gmane.org/gmane.linux.kernel 384*4882a593Smuzhiyun 385*4882a593SmuzhiyunIt is highly recommended that you search the archives about the topic 386*4882a593Smuzhiyunyou want to bring up, before you post it to the list. A lot of things 387*4882a593Smuzhiyunalready discussed in detail are only recorded at the mailing list 388*4882a593Smuzhiyunarchives. 389*4882a593Smuzhiyun 390*4882a593SmuzhiyunMost of the individual kernel subsystems also have their own separate 391*4882a593Smuzhiyunmailing list where they do their development efforts. See the 392*4882a593SmuzhiyunMAINTAINERS file for a list of what these lists are for the different 393*4882a593Smuzhiyungroups. 394*4882a593Smuzhiyun 395*4882a593SmuzhiyunMany of the lists are hosted on kernel.org. Information on them can be 396*4882a593Smuzhiyunfound at: 397*4882a593Smuzhiyun 398*4882a593Smuzhiyun http://vger.kernel.org/vger-lists.html 399*4882a593Smuzhiyun 400*4882a593SmuzhiyunPlease remember to follow good behavioral habits when using the lists. 401*4882a593SmuzhiyunThough a bit cheesy, the following URL has some simple guidelines for 402*4882a593Smuzhiyuninteracting with the list (or any list): 403*4882a593Smuzhiyun 404*4882a593Smuzhiyun http://www.albion.com/netiquette/ 405*4882a593Smuzhiyun 406*4882a593SmuzhiyunIf multiple people respond to your mail, the CC: list of recipients may 407*4882a593Smuzhiyunget pretty large. Don't remove anybody from the CC: list without a good 408*4882a593Smuzhiyunreason, or don't reply only to the list address. Get used to receiving the 409*4882a593Smuzhiyunmail twice, one from the sender and the one from the list, and don't try 410*4882a593Smuzhiyunto tune that by adding fancy mail-headers, people will not like it. 411*4882a593Smuzhiyun 412*4882a593SmuzhiyunRemember to keep the context and the attribution of your replies intact, 413*4882a593Smuzhiyunkeep the "John Kernelhacker wrote ...:" lines at the top of your reply, and 414*4882a593Smuzhiyunadd your statements between the individual quoted sections instead of 415*4882a593Smuzhiyunwriting at the top of the mail. 416*4882a593Smuzhiyun 417*4882a593SmuzhiyunIf you add patches to your mail, make sure they are plain readable text 418*4882a593Smuzhiyunas stated in :ref:`Documentation/process/submitting-patches.rst <submittingpatches>`. 419*4882a593SmuzhiyunKernel developers don't want to deal with 420*4882a593Smuzhiyunattachments or compressed patches; they may want to comment on 421*4882a593Smuzhiyunindividual lines of your patch, which works only that way. Make sure you 422*4882a593Smuzhiyunuse a mail program that does not mangle spaces and tab characters. A 423*4882a593Smuzhiyungood first test is to send the mail to yourself and try to apply your 424*4882a593Smuzhiyunown patch by yourself. If that doesn't work, get your mail program fixed 425*4882a593Smuzhiyunor change it until it works. 426*4882a593Smuzhiyun 427*4882a593SmuzhiyunAbove all, please remember to show respect to other subscribers. 428*4882a593Smuzhiyun 429*4882a593Smuzhiyun 430*4882a593SmuzhiyunWorking with the community 431*4882a593Smuzhiyun-------------------------- 432*4882a593Smuzhiyun 433*4882a593SmuzhiyunThe goal of the kernel community is to provide the best possible kernel 434*4882a593Smuzhiyunthere is. When you submit a patch for acceptance, it will be reviewed 435*4882a593Smuzhiyunon its technical merits and those alone. So, what should you be 436*4882a593Smuzhiyunexpecting? 437*4882a593Smuzhiyun 438*4882a593Smuzhiyun - criticism 439*4882a593Smuzhiyun - comments 440*4882a593Smuzhiyun - requests for change 441*4882a593Smuzhiyun - requests for justification 442*4882a593Smuzhiyun - silence 443*4882a593Smuzhiyun 444*4882a593SmuzhiyunRemember, this is part of getting your patch into the kernel. You have 445*4882a593Smuzhiyunto be able to take criticism and comments about your patches, evaluate 446*4882a593Smuzhiyunthem at a technical level and either rework your patches or provide 447*4882a593Smuzhiyunclear and concise reasoning as to why those changes should not be made. 448*4882a593SmuzhiyunIf there are no responses to your posting, wait a few days and try 449*4882a593Smuzhiyunagain, sometimes things get lost in the huge volume. 450*4882a593Smuzhiyun 451*4882a593SmuzhiyunWhat should you not do? 452*4882a593Smuzhiyun 453*4882a593Smuzhiyun - expect your patch to be accepted without question 454*4882a593Smuzhiyun - become defensive 455*4882a593Smuzhiyun - ignore comments 456*4882a593Smuzhiyun - resubmit the patch without making any of the requested changes 457*4882a593Smuzhiyun 458*4882a593SmuzhiyunIn a community that is looking for the best technical solution possible, 459*4882a593Smuzhiyunthere will always be differing opinions on how beneficial a patch is. 460*4882a593SmuzhiyunYou have to be cooperative, and willing to adapt your idea to fit within 461*4882a593Smuzhiyunthe kernel. Or at least be willing to prove your idea is worth it. 462*4882a593SmuzhiyunRemember, being wrong is acceptable as long as you are willing to work 463*4882a593Smuzhiyuntoward a solution that is right. 464*4882a593Smuzhiyun 465*4882a593SmuzhiyunIt is normal that the answers to your first patch might simply be a list 466*4882a593Smuzhiyunof a dozen things you should correct. This does **not** imply that your 467*4882a593Smuzhiyunpatch will not be accepted, and it is **not** meant against you 468*4882a593Smuzhiyunpersonally. Simply correct all issues raised against your patch and 469*4882a593Smuzhiyunresend it. 470*4882a593Smuzhiyun 471*4882a593Smuzhiyun 472*4882a593SmuzhiyunDifferences between the kernel community and corporate structures 473*4882a593Smuzhiyun----------------------------------------------------------------- 474*4882a593Smuzhiyun 475*4882a593SmuzhiyunThe kernel community works differently than most traditional corporate 476*4882a593Smuzhiyundevelopment environments. Here are a list of things that you can try to 477*4882a593Smuzhiyundo to avoid problems: 478*4882a593Smuzhiyun 479*4882a593Smuzhiyun Good things to say regarding your proposed changes: 480*4882a593Smuzhiyun 481*4882a593Smuzhiyun - "This solves multiple problems." 482*4882a593Smuzhiyun - "This deletes 2000 lines of code." 483*4882a593Smuzhiyun - "Here is a patch that explains what I am trying to describe." 484*4882a593Smuzhiyun - "I tested it on 5 different architectures..." 485*4882a593Smuzhiyun - "Here is a series of small patches that..." 486*4882a593Smuzhiyun - "This increases performance on typical machines..." 487*4882a593Smuzhiyun 488*4882a593Smuzhiyun Bad things you should avoid saying: 489*4882a593Smuzhiyun 490*4882a593Smuzhiyun - "We did it this way in AIX/ptx/Solaris, so therefore it must be 491*4882a593Smuzhiyun good..." 492*4882a593Smuzhiyun - "I've being doing this for 20 years, so..." 493*4882a593Smuzhiyun - "This is required for my company to make money" 494*4882a593Smuzhiyun - "This is for our Enterprise product line." 495*4882a593Smuzhiyun - "Here is my 1000 page design document that describes my idea" 496*4882a593Smuzhiyun - "I've been working on this for 6 months..." 497*4882a593Smuzhiyun - "Here's a 5000 line patch that..." 498*4882a593Smuzhiyun - "I rewrote all of the current mess, and here it is..." 499*4882a593Smuzhiyun - "I have a deadline, and this patch needs to be applied now." 500*4882a593Smuzhiyun 501*4882a593SmuzhiyunAnother way the kernel community is different than most traditional 502*4882a593Smuzhiyunsoftware engineering work environments is the faceless nature of 503*4882a593Smuzhiyuninteraction. One benefit of using email and irc as the primary forms of 504*4882a593Smuzhiyuncommunication is the lack of discrimination based on gender or race. 505*4882a593SmuzhiyunThe Linux kernel work environment is accepting of women and minorities 506*4882a593Smuzhiyunbecause all you are is an email address. The international aspect also 507*4882a593Smuzhiyunhelps to level the playing field because you can't guess gender based on 508*4882a593Smuzhiyuna person's name. A man may be named Andrea and a woman may be named Pat. 509*4882a593SmuzhiyunMost women who have worked in the Linux kernel and have expressed an 510*4882a593Smuzhiyunopinion have had positive experiences. 511*4882a593Smuzhiyun 512*4882a593SmuzhiyunThe language barrier can cause problems for some people who are not 513*4882a593Smuzhiyuncomfortable with English. A good grasp of the language can be needed in 514*4882a593Smuzhiyunorder to get ideas across properly on mailing lists, so it is 515*4882a593Smuzhiyunrecommended that you check your emails to make sure they make sense in 516*4882a593SmuzhiyunEnglish before sending them. 517*4882a593Smuzhiyun 518*4882a593Smuzhiyun 519*4882a593SmuzhiyunBreak up your changes 520*4882a593Smuzhiyun--------------------- 521*4882a593Smuzhiyun 522*4882a593SmuzhiyunThe Linux kernel community does not gladly accept large chunks of code 523*4882a593Smuzhiyundropped on it all at once. The changes need to be properly introduced, 524*4882a593Smuzhiyundiscussed, and broken up into tiny, individual portions. This is almost 525*4882a593Smuzhiyunthe exact opposite of what companies are used to doing. Your proposal 526*4882a593Smuzhiyunshould also be introduced very early in the development process, so that 527*4882a593Smuzhiyunyou can receive feedback on what you are doing. It also lets the 528*4882a593Smuzhiyuncommunity feel that you are working with them, and not simply using them 529*4882a593Smuzhiyunas a dumping ground for your feature. However, don't send 50 emails at 530*4882a593Smuzhiyunone time to a mailing list, your patch series should be smaller than 531*4882a593Smuzhiyunthat almost all of the time. 532*4882a593Smuzhiyun 533*4882a593SmuzhiyunThe reasons for breaking things up are the following: 534*4882a593Smuzhiyun 535*4882a593Smuzhiyun1) Small patches increase the likelihood that your patches will be 536*4882a593Smuzhiyun applied, since they don't take much time or effort to verify for 537*4882a593Smuzhiyun correctness. A 5 line patch can be applied by a maintainer with 538*4882a593Smuzhiyun barely a second glance. However, a 500 line patch may take hours to 539*4882a593Smuzhiyun review for correctness (the time it takes is exponentially 540*4882a593Smuzhiyun proportional to the size of the patch, or something). 541*4882a593Smuzhiyun 542*4882a593Smuzhiyun Small patches also make it very easy to debug when something goes 543*4882a593Smuzhiyun wrong. It's much easier to back out patches one by one than it is 544*4882a593Smuzhiyun to dissect a very large patch after it's been applied (and broken 545*4882a593Smuzhiyun something). 546*4882a593Smuzhiyun 547*4882a593Smuzhiyun2) It's important not only to send small patches, but also to rewrite 548*4882a593Smuzhiyun and simplify (or simply re-order) patches before submitting them. 549*4882a593Smuzhiyun 550*4882a593SmuzhiyunHere is an analogy from kernel developer Al Viro: 551*4882a593Smuzhiyun 552*4882a593Smuzhiyun *"Think of a teacher grading homework from a math student. The 553*4882a593Smuzhiyun teacher does not want to see the student's trials and errors 554*4882a593Smuzhiyun before they came up with the solution. They want to see the 555*4882a593Smuzhiyun cleanest, most elegant answer. A good student knows this, and 556*4882a593Smuzhiyun would never submit her intermediate work before the final 557*4882a593Smuzhiyun solution.* 558*4882a593Smuzhiyun 559*4882a593Smuzhiyun *The same is true of kernel development. The maintainers and 560*4882a593Smuzhiyun reviewers do not want to see the thought process behind the 561*4882a593Smuzhiyun solution to the problem one is solving. They want to see a 562*4882a593Smuzhiyun simple and elegant solution."* 563*4882a593Smuzhiyun 564*4882a593SmuzhiyunIt may be challenging to keep the balance between presenting an elegant 565*4882a593Smuzhiyunsolution and working together with the community and discussing your 566*4882a593Smuzhiyununfinished work. Therefore it is good to get early in the process to 567*4882a593Smuzhiyunget feedback to improve your work, but also keep your changes in small 568*4882a593Smuzhiyunchunks that they may get already accepted, even when your whole task is 569*4882a593Smuzhiyunnot ready for inclusion now. 570*4882a593Smuzhiyun 571*4882a593SmuzhiyunAlso realize that it is not acceptable to send patches for inclusion 572*4882a593Smuzhiyunthat are unfinished and will be "fixed up later." 573*4882a593Smuzhiyun 574*4882a593Smuzhiyun 575*4882a593SmuzhiyunJustify your change 576*4882a593Smuzhiyun------------------- 577*4882a593Smuzhiyun 578*4882a593SmuzhiyunAlong with breaking up your patches, it is very important for you to let 579*4882a593Smuzhiyunthe Linux community know why they should add this change. New features 580*4882a593Smuzhiyunmust be justified as being needed and useful. 581*4882a593Smuzhiyun 582*4882a593Smuzhiyun 583*4882a593SmuzhiyunDocument your change 584*4882a593Smuzhiyun-------------------- 585*4882a593Smuzhiyun 586*4882a593SmuzhiyunWhen sending in your patches, pay special attention to what you say in 587*4882a593Smuzhiyunthe text in your email. This information will become the ChangeLog 588*4882a593Smuzhiyuninformation for the patch, and will be preserved for everyone to see for 589*4882a593Smuzhiyunall time. It should describe the patch completely, containing: 590*4882a593Smuzhiyun 591*4882a593Smuzhiyun - why the change is necessary 592*4882a593Smuzhiyun - the overall design approach in the patch 593*4882a593Smuzhiyun - implementation details 594*4882a593Smuzhiyun - testing results 595*4882a593Smuzhiyun 596*4882a593SmuzhiyunFor more details on what this should all look like, please see the 597*4882a593SmuzhiyunChangeLog section of the document: 598*4882a593Smuzhiyun 599*4882a593Smuzhiyun "The Perfect Patch" 600*4882a593Smuzhiyun https://www.ozlabs.org/~akpm/stuff/tpp.txt 601*4882a593Smuzhiyun 602*4882a593Smuzhiyun 603*4882a593SmuzhiyunAll of these things are sometimes very hard to do. It can take years to 604*4882a593Smuzhiyunperfect these practices (if at all). It's a continuous process of 605*4882a593Smuzhiyunimprovement that requires a lot of patience and determination. But 606*4882a593Smuzhiyundon't give up, it's possible. Many have done it before, and each had to 607*4882a593Smuzhiyunstart exactly where you are now. 608*4882a593Smuzhiyun 609*4882a593Smuzhiyun 610*4882a593Smuzhiyun 611*4882a593Smuzhiyun 612*4882a593Smuzhiyun---------- 613*4882a593Smuzhiyun 614*4882a593SmuzhiyunThanks to Paolo Ciarrocchi who allowed the "Development Process" 615*4882a593Smuzhiyun(https://lwn.net/Articles/94386/) section 616*4882a593Smuzhiyunto be based on text he had written, and to Randy Dunlap and Gerrit 617*4882a593SmuzhiyunHuizenga for some of the list of things you should and should not say. 618*4882a593SmuzhiyunAlso thanks to Pat Mochel, Hanna Linder, Randy Dunlap, Kay Sievers, 619*4882a593SmuzhiyunVojtech Pavlik, Jan Kara, Josh Boyer, Kees Cook, Andrew Morton, Andi 620*4882a593SmuzhiyunKleen, Vadim Lobanov, Jesper Juhl, Adrian Bunk, Keri Harris, Frans Pop, 621*4882a593SmuzhiyunDavid A. Wheeler, Junio Hamano, Michael Kerrisk, and Alex Shepard for 622*4882a593Smuzhiyuntheir review, comments, and contributions. Without their help, this 623*4882a593Smuzhiyundocument would not have been possible. 624*4882a593Smuzhiyun 625*4882a593Smuzhiyun 626*4882a593Smuzhiyun 627*4882a593SmuzhiyunMaintainer: Greg Kroah-Hartman <greg@kroah.com> 628