162306a36Sopenharmony_ci.. _process_howto: 262306a36Sopenharmony_ci 362306a36Sopenharmony_ciHOWTO do Linux kernel development 462306a36Sopenharmony_ci================================= 562306a36Sopenharmony_ci 662306a36Sopenharmony_ciThis is the be-all, end-all document on this topic. It contains 762306a36Sopenharmony_ciinstructions on how to become a Linux kernel developer and how to learn 862306a36Sopenharmony_cito work with the Linux kernel development community. It tries to not 962306a36Sopenharmony_cicontain anything related to the technical aspects of kernel programming, 1062306a36Sopenharmony_cibut will help point you in the right direction for that. 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ciIf anything in this document becomes out of date, please send in patches 1362306a36Sopenharmony_cito the maintainer of this file, who is listed at the bottom of the 1462306a36Sopenharmony_cidocument. 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ciIntroduction 1862306a36Sopenharmony_ci------------ 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ciSo, you want to learn how to become a Linux kernel developer? Or you 2162306a36Sopenharmony_cihave been told by your manager, "Go write a Linux driver for this 2262306a36Sopenharmony_cidevice." This document's goal is to teach you everything you need to 2362306a36Sopenharmony_ciknow to achieve this by describing the process you need to go through, 2462306a36Sopenharmony_ciand hints on how to work with the community. It will also try to 2562306a36Sopenharmony_ciexplain some of the reasons why the community works like it does. 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ciThe kernel is written mostly in C, with some architecture-dependent 2862306a36Sopenharmony_ciparts written in assembly. A good understanding of C is required for 2962306a36Sopenharmony_cikernel development. Assembly (any architecture) is not required unless 3062306a36Sopenharmony_ciyou plan to do low-level development for that architecture. Though they 3162306a36Sopenharmony_ciare not a good substitute for a solid C education and/or years of 3262306a36Sopenharmony_ciexperience, the following books are good for, if anything, reference: 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci - "The C Programming Language" by Kernighan and Ritchie [Prentice Hall] 3562306a36Sopenharmony_ci - "Practical C Programming" by Steve Oualline [O'Reilly] 3662306a36Sopenharmony_ci - "C: A Reference Manual" by Harbison and Steele [Prentice Hall] 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ciThe kernel is written using GNU C and the GNU toolchain. While it 3962306a36Sopenharmony_ciadheres to the ISO C11 standard, it uses a number of extensions that are 4062306a36Sopenharmony_cinot featured in the standard. The kernel is a freestanding C 4162306a36Sopenharmony_cienvironment, with no reliance on the standard C library, so some 4262306a36Sopenharmony_ciportions of the C standard are not supported. Arbitrary long long 4362306a36Sopenharmony_cidivisions and floating point are not allowed. It can sometimes be 4462306a36Sopenharmony_cidifficult to understand the assumptions the kernel has on the toolchain 4562306a36Sopenharmony_ciand the extensions that it uses, and unfortunately there is no 4662306a36Sopenharmony_cidefinitive reference for them. Please check the gcc info pages (`info 4762306a36Sopenharmony_cigcc`) for some information on them. 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ciPlease remember that you are trying to learn how to work with the 5062306a36Sopenharmony_ciexisting development community. It is a diverse group of people, with 5162306a36Sopenharmony_cihigh standards for coding, style and procedure. These standards have 5262306a36Sopenharmony_cibeen created over time based on what they have found to work best for 5362306a36Sopenharmony_cisuch a large and geographically dispersed team. Try to learn as much as 5462306a36Sopenharmony_cipossible about these standards ahead of time, as they are well 5562306a36Sopenharmony_cidocumented; do not expect people to adapt to you or your company's way 5662306a36Sopenharmony_ciof doing things. 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ciLegal Issues 6062306a36Sopenharmony_ci------------ 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ciThe Linux kernel source code is released under the GPL. Please see the file 6362306a36Sopenharmony_ciCOPYING in the main directory of the source tree. The Linux kernel licensing 6462306a36Sopenharmony_cirules and how to use `SPDX <https://spdx.org/>`_ identifiers in source code are 6562306a36Sopenharmony_cidescribed in :ref:`Documentation/process/license-rules.rst <kernel_licensing>`. 6662306a36Sopenharmony_ciIf you have further questions about the license, please contact a lawyer, and do 6762306a36Sopenharmony_cinot ask on the Linux kernel mailing list. The people on the mailing lists are 6862306a36Sopenharmony_cinot lawyers, and you should not rely on their statements on legal matters. 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ciFor common questions and answers about the GPL, please see: 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci https://www.gnu.org/licenses/gpl-faq.html 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ciDocumentation 7662306a36Sopenharmony_ci------------- 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ciThe Linux kernel source tree has a large range of documents that are 7962306a36Sopenharmony_ciinvaluable for learning how to interact with the kernel community. When 8062306a36Sopenharmony_cinew features are added to the kernel, it is recommended that new 8162306a36Sopenharmony_cidocumentation files are also added which explain how to use the feature. 8262306a36Sopenharmony_ciWhen a kernel change causes the interface that the kernel exposes to 8362306a36Sopenharmony_ciuserspace to change, it is recommended that you send the information or 8462306a36Sopenharmony_cia patch to the manual pages explaining the change to the manual pages 8562306a36Sopenharmony_cimaintainer at mtk.manpages@gmail.com, and CC the list 8662306a36Sopenharmony_cilinux-api@vger.kernel.org. 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ciHere is a list of files that are in the kernel source tree that are 8962306a36Sopenharmony_cirequired reading: 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci :ref:`Documentation/admin-guide/README.rst <readme>` 9262306a36Sopenharmony_ci This file gives a short background on the Linux kernel and describes 9362306a36Sopenharmony_ci what is necessary to do to configure and build the kernel. People 9462306a36Sopenharmony_ci who are new to the kernel should start here. 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci :ref:`Documentation/process/changes.rst <changes>` 9762306a36Sopenharmony_ci This file gives a list of the minimum levels of various software 9862306a36Sopenharmony_ci packages that are necessary to build and run the kernel 9962306a36Sopenharmony_ci successfully. 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci :ref:`Documentation/process/coding-style.rst <codingstyle>` 10262306a36Sopenharmony_ci This describes the Linux kernel coding style, and some of the 10362306a36Sopenharmony_ci rationale behind it. All new code is expected to follow the 10462306a36Sopenharmony_ci guidelines in this document. Most maintainers will only accept 10562306a36Sopenharmony_ci patches if these rules are followed, and many people will only 10662306a36Sopenharmony_ci review code if it is in the proper style. 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci :ref:`Documentation/process/submitting-patches.rst <submittingpatches>` 10962306a36Sopenharmony_ci This file describes in explicit detail how to successfully create 11062306a36Sopenharmony_ci and send a patch, including (but not limited to): 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci - Email contents 11362306a36Sopenharmony_ci - Email format 11462306a36Sopenharmony_ci - Who to send it to 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci Following these rules will not guarantee success (as all patches are 11762306a36Sopenharmony_ci subject to scrutiny for content and style), but not following them 11862306a36Sopenharmony_ci will almost always prevent it. 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci Other excellent descriptions of how to create patches properly are: 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ci "The Perfect Patch" 12362306a36Sopenharmony_ci https://www.ozlabs.org/~akpm/stuff/tpp.txt 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci "Linux kernel patch submission format" 12662306a36Sopenharmony_ci https://web.archive.org/web/20180829112450/http://linux.yyz.us/patch-format.html 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci :ref:`Documentation/process/stable-api-nonsense.rst <stable_api_nonsense>` 12962306a36Sopenharmony_ci This file describes the rationale behind the conscious decision to 13062306a36Sopenharmony_ci not have a stable API within the kernel, including things like: 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci - Subsystem shim-layers (for compatibility?) 13362306a36Sopenharmony_ci - Driver portability between Operating Systems. 13462306a36Sopenharmony_ci - Mitigating rapid change within the kernel source tree (or 13562306a36Sopenharmony_ci preventing rapid change) 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci This document is crucial for understanding the Linux development 13862306a36Sopenharmony_ci philosophy and is very important for people moving to Linux from 13962306a36Sopenharmony_ci development on other Operating Systems. 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci :ref:`Documentation/process/security-bugs.rst <securitybugs>` 14262306a36Sopenharmony_ci If you feel you have found a security problem in the Linux kernel, 14362306a36Sopenharmony_ci please follow the steps in this document to help notify the kernel 14462306a36Sopenharmony_ci developers, and help solve the issue. 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci :ref:`Documentation/process/management-style.rst <managementstyle>` 14762306a36Sopenharmony_ci This document describes how Linux kernel maintainers operate and the 14862306a36Sopenharmony_ci shared ethos behind their methodologies. This is important reading 14962306a36Sopenharmony_ci for anyone new to kernel development (or anyone simply curious about 15062306a36Sopenharmony_ci it), as it resolves a lot of common misconceptions and confusion 15162306a36Sopenharmony_ci about the unique behavior of kernel maintainers. 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>` 15462306a36Sopenharmony_ci This file describes the rules on how the stable kernel releases 15562306a36Sopenharmony_ci happen, and what to do if you want to get a change into one of these 15662306a36Sopenharmony_ci releases. 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci :ref:`Documentation/process/kernel-docs.rst <kernel_docs>` 15962306a36Sopenharmony_ci A list of external documentation that pertains to kernel 16062306a36Sopenharmony_ci development. Please consult this list if you do not find what you 16162306a36Sopenharmony_ci are looking for within the in-kernel documentation. 16262306a36Sopenharmony_ci 16362306a36Sopenharmony_ci :ref:`Documentation/process/applying-patches.rst <applying_patches>` 16462306a36Sopenharmony_ci A good introduction describing exactly what a patch is and how to 16562306a36Sopenharmony_ci apply it to the different development branches of the kernel. 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_ciThe kernel also has a large number of documents that can be 16862306a36Sopenharmony_ciautomatically generated from the source code itself or from 16962306a36Sopenharmony_ciReStructuredText markups (ReST), like this one. This includes a 17062306a36Sopenharmony_cifull description of the in-kernel API, and rules on how to handle 17162306a36Sopenharmony_cilocking properly. 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ciAll such documents can be generated as PDF or HTML by running:: 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci make pdfdocs 17662306a36Sopenharmony_ci make htmldocs 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_cirespectively from the main kernel source directory. 17962306a36Sopenharmony_ci 18062306a36Sopenharmony_ciThe documents that uses ReST markup will be generated at Documentation/output. 18162306a36Sopenharmony_ciThey can also be generated on LaTeX and ePub formats with:: 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci make latexdocs 18462306a36Sopenharmony_ci make epubdocs 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_ciBecoming A Kernel Developer 18762306a36Sopenharmony_ci--------------------------- 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_ciIf you do not know anything about Linux kernel development, you should 19062306a36Sopenharmony_cilook at the Linux KernelNewbies project: 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ci https://kernelnewbies.org 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_ciIt consists of a helpful mailing list where you can ask almost any type 19562306a36Sopenharmony_ciof basic kernel development question (make sure to search the archives 19662306a36Sopenharmony_cifirst, before asking something that has already been answered in the 19762306a36Sopenharmony_cipast.) It also has an IRC channel that you can use to ask questions in 19862306a36Sopenharmony_cireal-time, and a lot of helpful documentation that is useful for 19962306a36Sopenharmony_cilearning about Linux kernel development. 20062306a36Sopenharmony_ci 20162306a36Sopenharmony_ciThe website has basic information about code organization, subsystems, 20262306a36Sopenharmony_ciand current projects (both in-tree and out-of-tree). It also describes 20362306a36Sopenharmony_cisome basic logistical information, like how to compile a kernel and 20462306a36Sopenharmony_ciapply a patch. 20562306a36Sopenharmony_ci 20662306a36Sopenharmony_ciIf you do not know where you want to start, but you want to look for 20762306a36Sopenharmony_cisome task to start doing to join into the kernel development community, 20862306a36Sopenharmony_cigo to the Linux Kernel Janitor's project: 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ci https://kernelnewbies.org/KernelJanitors 21162306a36Sopenharmony_ci 21262306a36Sopenharmony_ciIt is a great place to start. It describes a list of relatively simple 21362306a36Sopenharmony_ciproblems that need to be cleaned up and fixed within the Linux kernel 21462306a36Sopenharmony_cisource tree. Working with the developers in charge of this project, you 21562306a36Sopenharmony_ciwill learn the basics of getting your patch into the Linux kernel tree, 21662306a36Sopenharmony_ciand possibly be pointed in the direction of what to go work on next, if 21762306a36Sopenharmony_ciyou do not already have an idea. 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ciBefore making any actual modifications to the Linux kernel code, it is 22062306a36Sopenharmony_ciimperative to understand how the code in question works. For this 22162306a36Sopenharmony_cipurpose, nothing is better than reading through it directly (most tricky 22262306a36Sopenharmony_cibits are commented well), perhaps even with the help of specialized 22362306a36Sopenharmony_citools. One such tool that is particularly recommended is the Linux 22462306a36Sopenharmony_ciCross-Reference project, which is able to present source code in a 22562306a36Sopenharmony_ciself-referential, indexed webpage format. An excellent up-to-date 22662306a36Sopenharmony_cirepository of the kernel code may be found at: 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_ci https://elixir.bootlin.com/ 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_ciThe development process 23262306a36Sopenharmony_ci----------------------- 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ciLinux kernel development process currently consists of a few different 23562306a36Sopenharmony_cimain kernel "branches" and lots of different subsystem-specific kernel 23662306a36Sopenharmony_cibranches. These different branches are: 23762306a36Sopenharmony_ci 23862306a36Sopenharmony_ci - Linus's mainline tree 23962306a36Sopenharmony_ci - Various stable trees with multiple major numbers 24062306a36Sopenharmony_ci - Subsystem-specific trees 24162306a36Sopenharmony_ci - linux-next integration testing tree 24262306a36Sopenharmony_ci 24362306a36Sopenharmony_ciMainline tree 24462306a36Sopenharmony_ci~~~~~~~~~~~~~ 24562306a36Sopenharmony_ci 24662306a36Sopenharmony_ciThe mainline tree is maintained by Linus Torvalds, and can be found at 24762306a36Sopenharmony_cihttps://kernel.org or in the repo. Its development process is as follows: 24862306a36Sopenharmony_ci 24962306a36Sopenharmony_ci - As soon as a new kernel is released a two week window is open, 25062306a36Sopenharmony_ci during this period of time maintainers can submit big diffs to 25162306a36Sopenharmony_ci Linus, usually the patches that have already been included in the 25262306a36Sopenharmony_ci linux-next for a few weeks. The preferred way to submit big changes 25362306a36Sopenharmony_ci is using git (the kernel's source management tool, more information 25462306a36Sopenharmony_ci can be found at https://git-scm.com/) but plain patches are also just 25562306a36Sopenharmony_ci fine. 25662306a36Sopenharmony_ci - After two weeks a -rc1 kernel is released and the focus is on making the 25762306a36Sopenharmony_ci new kernel as rock solid as possible. Most of the patches at this point 25862306a36Sopenharmony_ci should fix a regression. Bugs that have always existed are not 25962306a36Sopenharmony_ci regressions, so only push these kinds of fixes if they are important. 26062306a36Sopenharmony_ci Please note that a whole new driver (or filesystem) might be accepted 26162306a36Sopenharmony_ci after -rc1 because there is no risk of causing regressions with such a 26262306a36Sopenharmony_ci change as long as the change is self-contained and does not affect areas 26362306a36Sopenharmony_ci outside of the code that is being added. git can be used to send 26462306a36Sopenharmony_ci patches to Linus after -rc1 is released, but the patches need to also be 26562306a36Sopenharmony_ci sent to a public mailing list for review. 26662306a36Sopenharmony_ci - A new -rc is released whenever Linus deems the current git tree to 26762306a36Sopenharmony_ci be in a reasonably sane state adequate for testing. The goal is to 26862306a36Sopenharmony_ci release a new -rc kernel every week. 26962306a36Sopenharmony_ci - Process continues until the kernel is considered "ready", the 27062306a36Sopenharmony_ci process should last around 6 weeks. 27162306a36Sopenharmony_ci 27262306a36Sopenharmony_ciIt is worth mentioning what Andrew Morton wrote on the linux-kernel 27362306a36Sopenharmony_cimailing list about kernel releases: 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_ci *"Nobody knows when a kernel will be released, because it's 27662306a36Sopenharmony_ci released according to perceived bug status, not according to a 27762306a36Sopenharmony_ci preconceived timeline."* 27862306a36Sopenharmony_ci 27962306a36Sopenharmony_ciVarious stable trees with multiple major numbers 28062306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 28162306a36Sopenharmony_ci 28262306a36Sopenharmony_ciKernels with 3-part versions are -stable kernels. They contain 28362306a36Sopenharmony_cirelatively small and critical fixes for security problems or significant 28462306a36Sopenharmony_ciregressions discovered in a given major mainline release. Each release 28562306a36Sopenharmony_ciin a major stable series increments the third part of the version 28662306a36Sopenharmony_cinumber, keeping the first two parts the same. 28762306a36Sopenharmony_ci 28862306a36Sopenharmony_ciThis is the recommended branch for users who want the most recent stable 28962306a36Sopenharmony_cikernel and are not interested in helping test development/experimental 29062306a36Sopenharmony_civersions. 29162306a36Sopenharmony_ci 29262306a36Sopenharmony_ciStable trees are maintained by the "stable" team <stable@vger.kernel.org>, and 29362306a36Sopenharmony_ciare released as needs dictate. The normal release period is approximately 29462306a36Sopenharmony_citwo weeks, but it can be longer if there are no pressing problems. A 29562306a36Sopenharmony_cisecurity-related problem, instead, can cause a release to happen almost 29662306a36Sopenharmony_ciinstantly. 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ciThe file :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>` 29962306a36Sopenharmony_ciin the kernel tree documents what kinds of changes are acceptable for 30062306a36Sopenharmony_cithe -stable tree, and how the release process works. 30162306a36Sopenharmony_ci 30262306a36Sopenharmony_ciSubsystem-specific trees 30362306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~ 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_ciThe maintainers of the various kernel subsystems --- and also many 30662306a36Sopenharmony_cikernel subsystem developers --- expose their current state of 30762306a36Sopenharmony_cidevelopment in source repositories. That way, others can see what is 30862306a36Sopenharmony_cihappening in the different areas of the kernel. In areas where 30962306a36Sopenharmony_cidevelopment is rapid, a developer may be asked to base his submissions 31062306a36Sopenharmony_cionto such a subsystem kernel tree so that conflicts between the 31162306a36Sopenharmony_cisubmission and other already ongoing work are avoided. 31262306a36Sopenharmony_ci 31362306a36Sopenharmony_ciMost of these repositories are git trees, but there are also other SCMs 31462306a36Sopenharmony_ciin use, or patch queues being published as quilt series. Addresses of 31562306a36Sopenharmony_cithese subsystem repositories are listed in the MAINTAINERS file. Many 31662306a36Sopenharmony_ciof them can be browsed at https://git.kernel.org/. 31762306a36Sopenharmony_ci 31862306a36Sopenharmony_ciBefore a proposed patch is committed to such a subsystem tree, it is 31962306a36Sopenharmony_cisubject to review which primarily happens on mailing lists (see the 32062306a36Sopenharmony_cirespective section below). For several kernel subsystems, this review 32162306a36Sopenharmony_ciprocess is tracked with the tool patchwork. Patchwork offers a web 32262306a36Sopenharmony_ciinterface which shows patch postings, any comments on a patch or 32362306a36Sopenharmony_cirevisions to it, and maintainers can mark patches as under review, 32462306a36Sopenharmony_ciaccepted, or rejected. Most of these patchwork sites are listed at 32562306a36Sopenharmony_cihttps://patchwork.kernel.org/. 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_cilinux-next integration testing tree 32862306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 32962306a36Sopenharmony_ci 33062306a36Sopenharmony_ciBefore updates from subsystem trees are merged into the mainline tree, 33162306a36Sopenharmony_cithey need to be integration-tested. For this purpose, a special 33262306a36Sopenharmony_citesting repository exists into which virtually all subsystem trees are 33362306a36Sopenharmony_cipulled on an almost daily basis: 33462306a36Sopenharmony_ci 33562306a36Sopenharmony_ci https://git.kernel.org/?p=linux/kernel/git/next/linux-next.git 33662306a36Sopenharmony_ci 33762306a36Sopenharmony_ciThis way, the linux-next gives a summary outlook onto what will be 33862306a36Sopenharmony_ciexpected to go into the mainline kernel at the next merge period. 33962306a36Sopenharmony_ciAdventurous testers are very welcome to runtime-test the linux-next. 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci 34262306a36Sopenharmony_ciBug Reporting 34362306a36Sopenharmony_ci------------- 34462306a36Sopenharmony_ci 34562306a36Sopenharmony_ciThe file 'Documentation/admin-guide/reporting-issues.rst' in the main kernel 34662306a36Sopenharmony_cisource directory describes how to report a possible kernel bug, and details 34762306a36Sopenharmony_ciwhat kind of information is needed by the kernel developers to help track 34862306a36Sopenharmony_cidown the problem. 34962306a36Sopenharmony_ci 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_ciManaging bug reports 35262306a36Sopenharmony_ci-------------------- 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_ciOne of the best ways to put into practice your hacking skills is by fixing 35562306a36Sopenharmony_cibugs reported by other people. Not only you will help to make the kernel 35662306a36Sopenharmony_cimore stable, but you'll also learn to fix real world problems and you will 35762306a36Sopenharmony_ciimprove your skills, and other developers will be aware of your presence. 35862306a36Sopenharmony_ciFixing bugs is one of the best ways to get merits among other developers, 35962306a36Sopenharmony_cibecause not many people like wasting time fixing other people's bugs. 36062306a36Sopenharmony_ci 36162306a36Sopenharmony_ciTo work on already reported bug reports, find a subsystem you are interested in. 36262306a36Sopenharmony_ciCheck the MAINTAINERS file where bugs for that subsystem get reported to; often 36362306a36Sopenharmony_ciit will be a mailing list, rarely a bugtracker. Search the archives of said 36462306a36Sopenharmony_ciplace for recent reports and help where you see fit. You may also want to check 36562306a36Sopenharmony_cihttps://bugzilla.kernel.org for bug reports; only a handful of kernel subsystems 36662306a36Sopenharmony_ciuse it actively for reporting or tracking, nevertheless bugs for the whole 36762306a36Sopenharmony_cikernel get filed there. 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ciMailing lists 37162306a36Sopenharmony_ci------------- 37262306a36Sopenharmony_ci 37362306a36Sopenharmony_ciAs some of the above documents describe, the majority of the core kernel 37462306a36Sopenharmony_cidevelopers participate on the Linux Kernel Mailing list. Details on how 37562306a36Sopenharmony_cito subscribe and unsubscribe from the list can be found at: 37662306a36Sopenharmony_ci 37762306a36Sopenharmony_ci http://vger.kernel.org/vger-lists.html#linux-kernel 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_ciThere are archives of the mailing list on the web in many different 38062306a36Sopenharmony_ciplaces. Use a search engine to find these archives. For example: 38162306a36Sopenharmony_ci 38262306a36Sopenharmony_ci https://lore.kernel.org/lkml/ 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_ciIt is highly recommended that you search the archives about the topic 38562306a36Sopenharmony_ciyou want to bring up, before you post it to the list. A lot of things 38662306a36Sopenharmony_cialready discussed in detail are only recorded at the mailing list 38762306a36Sopenharmony_ciarchives. 38862306a36Sopenharmony_ci 38962306a36Sopenharmony_ciMost of the individual kernel subsystems also have their own separate 39062306a36Sopenharmony_cimailing list where they do their development efforts. See the 39162306a36Sopenharmony_ciMAINTAINERS file for a list of what these lists are for the different 39262306a36Sopenharmony_cigroups. 39362306a36Sopenharmony_ci 39462306a36Sopenharmony_ciMany of the lists are hosted on kernel.org. Information on them can be 39562306a36Sopenharmony_cifound at: 39662306a36Sopenharmony_ci 39762306a36Sopenharmony_ci http://vger.kernel.org/vger-lists.html 39862306a36Sopenharmony_ci 39962306a36Sopenharmony_ciPlease remember to follow good behavioral habits when using the lists. 40062306a36Sopenharmony_ciThough a bit cheesy, the following URL has some simple guidelines for 40162306a36Sopenharmony_ciinteracting with the list (or any list): 40262306a36Sopenharmony_ci 40362306a36Sopenharmony_ci http://www.albion.com/netiquette/ 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ciIf multiple people respond to your mail, the CC: list of recipients may 40662306a36Sopenharmony_ciget pretty large. Don't remove anybody from the CC: list without a good 40762306a36Sopenharmony_cireason, or don't reply only to the list address. Get used to receiving the 40862306a36Sopenharmony_cimail twice, one from the sender and the one from the list, and don't try 40962306a36Sopenharmony_cito tune that by adding fancy mail-headers, people will not like it. 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_ciRemember to keep the context and the attribution of your replies intact, 41262306a36Sopenharmony_cikeep the "John Kernelhacker wrote ...:" lines at the top of your reply, and 41362306a36Sopenharmony_ciadd your statements between the individual quoted sections instead of 41462306a36Sopenharmony_ciwriting at the top of the mail. 41562306a36Sopenharmony_ci 41662306a36Sopenharmony_ciIf you add patches to your mail, make sure they are plain readable text 41762306a36Sopenharmony_cias stated in :ref:`Documentation/process/submitting-patches.rst <submittingpatches>`. 41862306a36Sopenharmony_ciKernel developers don't want to deal with 41962306a36Sopenharmony_ciattachments or compressed patches; they may want to comment on 42062306a36Sopenharmony_ciindividual lines of your patch, which works only that way. Make sure you 42162306a36Sopenharmony_ciuse a mail program that does not mangle spaces and tab characters. A 42262306a36Sopenharmony_cigood first test is to send the mail to yourself and try to apply your 42362306a36Sopenharmony_ciown patch by yourself. If that doesn't work, get your mail program fixed 42462306a36Sopenharmony_cior change it until it works. 42562306a36Sopenharmony_ci 42662306a36Sopenharmony_ciAbove all, please remember to show respect to other subscribers. 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_ci 42962306a36Sopenharmony_ciWorking with the community 43062306a36Sopenharmony_ci-------------------------- 43162306a36Sopenharmony_ci 43262306a36Sopenharmony_ciThe goal of the kernel community is to provide the best possible kernel 43362306a36Sopenharmony_cithere is. When you submit a patch for acceptance, it will be reviewed 43462306a36Sopenharmony_cion its technical merits and those alone. So, what should you be 43562306a36Sopenharmony_ciexpecting? 43662306a36Sopenharmony_ci 43762306a36Sopenharmony_ci - criticism 43862306a36Sopenharmony_ci - comments 43962306a36Sopenharmony_ci - requests for change 44062306a36Sopenharmony_ci - requests for justification 44162306a36Sopenharmony_ci - silence 44262306a36Sopenharmony_ci 44362306a36Sopenharmony_ciRemember, this is part of getting your patch into the kernel. You have 44462306a36Sopenharmony_cito be able to take criticism and comments about your patches, evaluate 44562306a36Sopenharmony_cithem at a technical level and either rework your patches or provide 44662306a36Sopenharmony_ciclear and concise reasoning as to why those changes should not be made. 44762306a36Sopenharmony_ciIf there are no responses to your posting, wait a few days and try 44862306a36Sopenharmony_ciagain, sometimes things get lost in the huge volume. 44962306a36Sopenharmony_ci 45062306a36Sopenharmony_ciWhat should you not do? 45162306a36Sopenharmony_ci 45262306a36Sopenharmony_ci - expect your patch to be accepted without question 45362306a36Sopenharmony_ci - become defensive 45462306a36Sopenharmony_ci - ignore comments 45562306a36Sopenharmony_ci - resubmit the patch without making any of the requested changes 45662306a36Sopenharmony_ci 45762306a36Sopenharmony_ciIn a community that is looking for the best technical solution possible, 45862306a36Sopenharmony_cithere will always be differing opinions on how beneficial a patch is. 45962306a36Sopenharmony_ciYou have to be cooperative, and willing to adapt your idea to fit within 46062306a36Sopenharmony_cithe kernel. Or at least be willing to prove your idea is worth it. 46162306a36Sopenharmony_ciRemember, being wrong is acceptable as long as you are willing to work 46262306a36Sopenharmony_citoward a solution that is right. 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_ciIt is normal that the answers to your first patch might simply be a list 46562306a36Sopenharmony_ciof a dozen things you should correct. This does **not** imply that your 46662306a36Sopenharmony_cipatch will not be accepted, and it is **not** meant against you 46762306a36Sopenharmony_cipersonally. Simply correct all issues raised against your patch and 46862306a36Sopenharmony_ciresend it. 46962306a36Sopenharmony_ci 47062306a36Sopenharmony_ci 47162306a36Sopenharmony_ciDifferences between the kernel community and corporate structures 47262306a36Sopenharmony_ci----------------------------------------------------------------- 47362306a36Sopenharmony_ci 47462306a36Sopenharmony_ciThe kernel community works differently than most traditional corporate 47562306a36Sopenharmony_cidevelopment environments. Here are a list of things that you can try to 47662306a36Sopenharmony_cido to avoid problems: 47762306a36Sopenharmony_ci 47862306a36Sopenharmony_ci Good things to say regarding your proposed changes: 47962306a36Sopenharmony_ci 48062306a36Sopenharmony_ci - "This solves multiple problems." 48162306a36Sopenharmony_ci - "This deletes 2000 lines of code." 48262306a36Sopenharmony_ci - "Here is a patch that explains what I am trying to describe." 48362306a36Sopenharmony_ci - "I tested it on 5 different architectures..." 48462306a36Sopenharmony_ci - "Here is a series of small patches that..." 48562306a36Sopenharmony_ci - "This increases performance on typical machines..." 48662306a36Sopenharmony_ci 48762306a36Sopenharmony_ci Bad things you should avoid saying: 48862306a36Sopenharmony_ci 48962306a36Sopenharmony_ci - "We did it this way in AIX/ptx/Solaris, so therefore it must be 49062306a36Sopenharmony_ci good..." 49162306a36Sopenharmony_ci - "I've being doing this for 20 years, so..." 49262306a36Sopenharmony_ci - "This is required for my company to make money" 49362306a36Sopenharmony_ci - "This is for our Enterprise product line." 49462306a36Sopenharmony_ci - "Here is my 1000 page design document that describes my idea" 49562306a36Sopenharmony_ci - "I've been working on this for 6 months..." 49662306a36Sopenharmony_ci - "Here's a 5000 line patch that..." 49762306a36Sopenharmony_ci - "I rewrote all of the current mess, and here it is..." 49862306a36Sopenharmony_ci - "I have a deadline, and this patch needs to be applied now." 49962306a36Sopenharmony_ci 50062306a36Sopenharmony_ciAnother way the kernel community is different than most traditional 50162306a36Sopenharmony_cisoftware engineering work environments is the faceless nature of 50262306a36Sopenharmony_ciinteraction. One benefit of using email and irc as the primary forms of 50362306a36Sopenharmony_cicommunication is the lack of discrimination based on gender or race. 50462306a36Sopenharmony_ciThe Linux kernel work environment is accepting of women and minorities 50562306a36Sopenharmony_cibecause all you are is an email address. The international aspect also 50662306a36Sopenharmony_cihelps to level the playing field because you can't guess gender based on 50762306a36Sopenharmony_cia person's name. A man may be named Andrea and a woman may be named Pat. 50862306a36Sopenharmony_ciMost women who have worked in the Linux kernel and have expressed an 50962306a36Sopenharmony_ciopinion have had positive experiences. 51062306a36Sopenharmony_ci 51162306a36Sopenharmony_ciThe language barrier can cause problems for some people who are not 51262306a36Sopenharmony_cicomfortable with English. A good grasp of the language can be needed in 51362306a36Sopenharmony_ciorder to get ideas across properly on mailing lists, so it is 51462306a36Sopenharmony_cirecommended that you check your emails to make sure they make sense in 51562306a36Sopenharmony_ciEnglish before sending them. 51662306a36Sopenharmony_ci 51762306a36Sopenharmony_ci 51862306a36Sopenharmony_ciBreak up your changes 51962306a36Sopenharmony_ci--------------------- 52062306a36Sopenharmony_ci 52162306a36Sopenharmony_ciThe Linux kernel community does not gladly accept large chunks of code 52262306a36Sopenharmony_cidropped on it all at once. The changes need to be properly introduced, 52362306a36Sopenharmony_cidiscussed, and broken up into tiny, individual portions. This is almost 52462306a36Sopenharmony_cithe exact opposite of what companies are used to doing. Your proposal 52562306a36Sopenharmony_cishould also be introduced very early in the development process, so that 52662306a36Sopenharmony_ciyou can receive feedback on what you are doing. It also lets the 52762306a36Sopenharmony_cicommunity feel that you are working with them, and not simply using them 52862306a36Sopenharmony_cias a dumping ground for your feature. However, don't send 50 emails at 52962306a36Sopenharmony_cione time to a mailing list, your patch series should be smaller than 53062306a36Sopenharmony_cithat almost all of the time. 53162306a36Sopenharmony_ci 53262306a36Sopenharmony_ciThe reasons for breaking things up are the following: 53362306a36Sopenharmony_ci 53462306a36Sopenharmony_ci1) Small patches increase the likelihood that your patches will be 53562306a36Sopenharmony_ci applied, since they don't take much time or effort to verify for 53662306a36Sopenharmony_ci correctness. A 5 line patch can be applied by a maintainer with 53762306a36Sopenharmony_ci barely a second glance. However, a 500 line patch may take hours to 53862306a36Sopenharmony_ci review for correctness (the time it takes is exponentially 53962306a36Sopenharmony_ci proportional to the size of the patch, or something). 54062306a36Sopenharmony_ci 54162306a36Sopenharmony_ci Small patches also make it very easy to debug when something goes 54262306a36Sopenharmony_ci wrong. It's much easier to back out patches one by one than it is 54362306a36Sopenharmony_ci to dissect a very large patch after it's been applied (and broken 54462306a36Sopenharmony_ci something). 54562306a36Sopenharmony_ci 54662306a36Sopenharmony_ci2) It's important not only to send small patches, but also to rewrite 54762306a36Sopenharmony_ci and simplify (or simply re-order) patches before submitting them. 54862306a36Sopenharmony_ci 54962306a36Sopenharmony_ciHere is an analogy from kernel developer Al Viro: 55062306a36Sopenharmony_ci 55162306a36Sopenharmony_ci *"Think of a teacher grading homework from a math student. The 55262306a36Sopenharmony_ci teacher does not want to see the student's trials and errors 55362306a36Sopenharmony_ci before they came up with the solution. They want to see the 55462306a36Sopenharmony_ci cleanest, most elegant answer. A good student knows this, and 55562306a36Sopenharmony_ci would never submit her intermediate work before the final 55662306a36Sopenharmony_ci solution.* 55762306a36Sopenharmony_ci 55862306a36Sopenharmony_ci *The same is true of kernel development. The maintainers and 55962306a36Sopenharmony_ci reviewers do not want to see the thought process behind the 56062306a36Sopenharmony_ci solution to the problem one is solving. They want to see a 56162306a36Sopenharmony_ci simple and elegant solution."* 56262306a36Sopenharmony_ci 56362306a36Sopenharmony_ciIt may be challenging to keep the balance between presenting an elegant 56462306a36Sopenharmony_cisolution and working together with the community and discussing your 56562306a36Sopenharmony_ciunfinished work. Therefore it is good to get early in the process to 56662306a36Sopenharmony_ciget feedback to improve your work, but also keep your changes in small 56762306a36Sopenharmony_cichunks that they may get already accepted, even when your whole task is 56862306a36Sopenharmony_cinot ready for inclusion now. 56962306a36Sopenharmony_ci 57062306a36Sopenharmony_ciAlso realize that it is not acceptable to send patches for inclusion 57162306a36Sopenharmony_cithat are unfinished and will be "fixed up later." 57262306a36Sopenharmony_ci 57362306a36Sopenharmony_ci 57462306a36Sopenharmony_ciJustify your change 57562306a36Sopenharmony_ci------------------- 57662306a36Sopenharmony_ci 57762306a36Sopenharmony_ciAlong with breaking up your patches, it is very important for you to let 57862306a36Sopenharmony_cithe Linux community know why they should add this change. New features 57962306a36Sopenharmony_cimust be justified as being needed and useful. 58062306a36Sopenharmony_ci 58162306a36Sopenharmony_ci 58262306a36Sopenharmony_ciDocument your change 58362306a36Sopenharmony_ci-------------------- 58462306a36Sopenharmony_ci 58562306a36Sopenharmony_ciWhen sending in your patches, pay special attention to what you say in 58662306a36Sopenharmony_cithe text in your email. This information will become the ChangeLog 58762306a36Sopenharmony_ciinformation for the patch, and will be preserved for everyone to see for 58862306a36Sopenharmony_ciall time. It should describe the patch completely, containing: 58962306a36Sopenharmony_ci 59062306a36Sopenharmony_ci - why the change is necessary 59162306a36Sopenharmony_ci - the overall design approach in the patch 59262306a36Sopenharmony_ci - implementation details 59362306a36Sopenharmony_ci - testing results 59462306a36Sopenharmony_ci 59562306a36Sopenharmony_ciFor more details on what this should all look like, please see the 59662306a36Sopenharmony_ciChangeLog section of the document: 59762306a36Sopenharmony_ci 59862306a36Sopenharmony_ci "The Perfect Patch" 59962306a36Sopenharmony_ci https://www.ozlabs.org/~akpm/stuff/tpp.txt 60062306a36Sopenharmony_ci 60162306a36Sopenharmony_ci 60262306a36Sopenharmony_ciAll of these things are sometimes very hard to do. It can take years to 60362306a36Sopenharmony_ciperfect these practices (if at all). It's a continuous process of 60462306a36Sopenharmony_ciimprovement that requires a lot of patience and determination. But 60562306a36Sopenharmony_cidon't give up, it's possible. Many have done it before, and each had to 60662306a36Sopenharmony_cistart exactly where you are now. 60762306a36Sopenharmony_ci 60862306a36Sopenharmony_ci 60962306a36Sopenharmony_ci 61062306a36Sopenharmony_ci 61162306a36Sopenharmony_ci---------- 61262306a36Sopenharmony_ci 61362306a36Sopenharmony_ciThanks to Paolo Ciarrocchi who allowed the "Development Process" 61462306a36Sopenharmony_ci(https://lwn.net/Articles/94386/) section 61562306a36Sopenharmony_cito be based on text he had written, and to Randy Dunlap and Gerrit 61662306a36Sopenharmony_ciHuizenga for some of the list of things you should and should not say. 61762306a36Sopenharmony_ciAlso thanks to Pat Mochel, Hanna Linder, Randy Dunlap, Kay Sievers, 61862306a36Sopenharmony_ciVojtech Pavlik, Jan Kara, Josh Boyer, Kees Cook, Andrew Morton, Andi 61962306a36Sopenharmony_ciKleen, Vadim Lobanov, Jesper Juhl, Adrian Bunk, Keri Harris, Frans Pop, 62062306a36Sopenharmony_ciDavid A. Wheeler, Junio Hamano, Michael Kerrisk, and Alex Shepard for 62162306a36Sopenharmony_citheir review, comments, and contributions. Without their help, this 62262306a36Sopenharmony_cidocument would not have been possible. 62362306a36Sopenharmony_ci 62462306a36Sopenharmony_ci 62562306a36Sopenharmony_ci 62662306a36Sopenharmony_ciMaintainer: Greg Kroah-Hartman <greg@kroah.com> 627