The HOWTO file I posted is going to go into the main kernel tree soon, but I wanted to place it here, online, for others to see, like the other Documentation files I have written. I want to keep it all together in one file, as breaking it up in the kernel tree would be messy. I also want a single place to refer people to, due to the questions that always come up that this file answers. It's also to get some good Google juice for it, which will help people find it on their own (my eventual goal.) I tried to properly recognize the individual authors who helped out by crediting them at the end of the file, and everyone can see the changes broken down by person and line changed in my public git tree. I also did not put my name on the top of the file as the author on purpose, like I have done with other files, as this was a group effort, and I have never hidden that. I only list myself as the maintainer at the end as someone needs to maintain it over time and keep it up to date. posted Thu, 17 Nov 2005 in [/diary]
I'm giving my "Write a real, working Linux driver" tutorial again next week at the Linux Users Group of Oregon State University. For more information, of if you are going to be in the area and want to attend, look at the announcement. Should be a lot of fun, and you get a working, USB thermometer from Vernier, so there is no excuse for not showing up and heckling me. posted Thu, 17 Nov 2005 in [/diary]
Everything you ever wanted to know about Linux kernel proceedures. This is the be-all, end-all document on this topic. It contains instructions on how to become a Linux kernel developer and how to learn to work with the Linux kernel development community. It tries to not contain anything related to the technical aspects of kernel programming, but will help point you in the right direction for that. If anything in this document becomes out of date, please send in patches to the maintainer of this file, who is listed at the bottom of the document. IntroductionSo, you want to learn how to become a Linux kernel developer? Or you have been told by your manager, "Go write a Linux driver for this device." This document's goal is to teach you everything you need to know to achieve this by describing the process you need to go through, and hints on how to work with the community. It will also try to explain some of the reasons why the community works like it does. The kernel is written mostly in C, with some architecture-dependent parts written in assembly. A good understanding of C is required for kernel development. Assembly (any architecture) is not required unless you plan to do low-level development for that architecture. Though they are not a good substitute for a solid C education and/or years of experience, the following books are good for, if anything, reference:
The kernel is written using GNU C and the GNU toolchain. While it
adheres to the ISO C89 standard, it uses a number of extensions that are
not featured in the standard. The kernel is a freestanding C
environment, with no reliance on the standard C library, so some
portions of the C standard are not supported. Arbitrary long long
divisions and floating point are not allowed. It can sometimes be
difficult to understand the assumptions the kernel has on the toolchain
and the extensions that it uses, and unfortunately there is no
definitive reference for them. Please check the gcc info pages ( Please remember that you are trying to learn how to work with the existing development community. It is a diverse group of people, with high standards for coding, style and procedure. These standards have been created over time based on what they have found to work best for such a large and geographically dispersed team. Try to learn as much as possible about these standards ahead of time, as they are well documented; do not expect people to adapt to you or your company's way of doing things. Legal IssuesThe Linux kernel source code is released under the GPL. Please see the file, COPYING, in the main directory of the source tree, for details on the license. If you have further questions about the license, please contact a lawyer, and do not ask on the Linux kernel mailing list. The people on the mailing lists are not lawyers, and you should not rely on their statements on legal matters. For common questions and answers about the GPL, please see: http://www.gnu.org/licenses/gpl-faq.html DocumentationThe Linux kernel source tree has a large range of documents that are invaluable for learning how to interact with the kernel community. When new features are added to the kernel, it is recommended that new documentation files are also added which explain how to use the feature. When a kernel change causes the interface that the kernel exposes to userspace to change, it is recommended that you send the information or a patch to the manual pages explaining the change to the manual pages maintainer at mtk-manpages@gmx.net. Here is a list of files that are in the kernel source tree that are required reading:
respectively from the main kernel source directory.
Becoming A Kernel DeveloperIf you do not know anything about Linux kernel development, you should look at the Linux KernelNewbies project:The development processLinux kernel development process currently consists of a few different main kernel "branches" and lots of different subsystem-specific kernel branches. These different branches are:
2.6.x kernel tree2.6.x kernels are maintained by Linus Torvalds, and can be found on kernel.org in the pub/linux/kernel/v2.6/ directory. Its development process is as follows:
2.6.x.y -stable kernel treeKernels with 4 digit versions are -stable kernels. They contain relatively small and critical fixes for security problems or significant regressions discovered in a given 2.6.x kernel. This is the recommended branch for users who want the most recent stable kernel and are not interested in helping test development/experimental versions. If no 2.6.x.y kernel is available, then the highest numbered 2.6.x kernel is the current stable kernel. 2.6.x.y are maintained by the "stable" team stable@kernel.org, and are released almost every other week. The file Documentation/stablekernelrules.txt in the kernel tree documents what kinds of changes are acceptable for the -stable tree, and how the release process works. 2.6.x -git patchesThese are daily snapshots of Linus' kernel tree which are managed in a git repository (hence the name.) These patches are usually released daily and represent the current state of Linus' tree. They are more experimental than -rc kernels since they are generated automatically without even a cursory glance to see if they are sane. 2.6.x -mm kernel patchesThese are experimental kernel patches released by Andrew Morton. Andrew takes all of the different subsystem kernel trees and patches and mushes them together, along with a lot of patches that have been plucked from the linux-kernel mailing list. This tree serves as a proving ground for new features and patches. Once a patch has proved its worth in -mm for a while Andrew or the subsystem maintainer pushes it on to Linus for inclusion in mainline. It is heavily encouraged that all new patches get tested in the -mm tree before they are sent to Linus for inclusion in the main kernel tree. These kernels are not appropriate for use on systems that are supposed to be stable and they are more risky to run than any of the other branches. If you wish to help out with the kernel development process, please test and use these kernel releases and provide feedback to the linux-kernel mailing list if you have any problems, and if everything works properly. In addition to all the other experimental patches, these kernels usually also contain any changes in the mainline -git kernels available at the time of release. The -mm kernels are not released on a fixed schedule, but usually a few -mm kernels are released in between each -rc kernel (1 to 3 is common). Subsystem Specific kernel trees and patchesA number of the different kernel subsystem developers expose their development trees so that others can see what is happening in the different areas of the kernel. These trees are pulled into the -mm kernel releases as described above. Here is a list of some of the different kernel trees available: git trees:
Other git kernel trees can be found listed at http://kernel.org/git quilt trees:
Bug ReportingThe file REPORTING-BUGS in the main kernel source directory has a good template for how to report a possible kernel bug, and details what kind of information is needed by the kernel developers to help track down the problem. Mailing listsAs some of the above documents describe, the majority of the core kernel developers participate on the Linux Kernel Mailing list. Details on how to subscribe and unsubscribe from the list can be found at: http://vger.kernel.org/vger-lists.html#linux-kernel There are archives of the mailing list on the web in many different places. Use a search engine to find these archives. For example: http://dir.gmane.org/gmane.linux.kernel It is highly recommended that you search the archives about the topic you want to bring up, before you post it to the list. A lot of things already discussed in detail are only recorded at the mailing list archives. Most of the individual kernel subsystems also have their own separate mailing list where they do their development efforts. See the MAINTAINERS file for a list of what these lists are for the different groups. Many of the lists are hosted on kernel.org. Information on them can be found at: http://vger.kernel.org/vger-lists.html Please remember to follow good behavioral habits when using the lists. Though a bit cheesy, the following URL has some simple guidelines for interacting with the list (or any list): http://www.albion.com/netiquette/ If multiple people respond to your mail, the CC: list of recipients may get pretty large. Don't remove anybody from the CC: list without a good reason, or don't reply only to the list address. Get used to receiving the mail twice, one from the sender and the one from the list, and don't try to tune that by adding fancy mail-headers, people will not like it. Remember to keep the context and the attribution of your replies intact, keep the "John Kernelhacker wrote ...:" lines at the top of your reply, and add your statements between the individual quoted sections instead of writing at the top of the mail. If you add patches to your mail, make sure they are plain readable text as stated in Documentation/SubmittingPatches. Kernel developers don't want to deal with attachments or compressed patches; they may want to comment on individual lines of your patch, which works only that way. Make sure you use a mail program that does not mangle spaces and tab characters. A good first test is to send the mail to yourself and try to apply your own patch by yourself. If that doesn't work, get your mail program fixed or change it until it works. Above all, please remember to show respect to other subscribers. Working with the communityThe goal of the kernel community is to provide the best possible kernel there is. When you submit a patch for acceptance, it will be reviewed on its technical merits and those alone. So, what should you be expecting?
Remember, this is part of getting your patch into the kernel. You have to be able to take criticism and comments about your patches, evaluate them at a technical level and either rework your patches or provide clear and concise reasoning as to why those changes should not be made. If there are no responses to your posting, wait a few days and try again, sometimes things get lost in the huge volume. What should you not do?
In a community that is looking for the best technical solution possible, there will always be differing opinions on how beneficial a patch is. You have to be cooperative, and willing to adapt your idea to fit within the kernel. Or at least be willing to prove your idea is worth it. Remember, being wrong is acceptable as long as you are willing to work toward a solution that is right. It is normal that the answers to your first patch might simply be a list of a dozen things you should correct. This does not imply that your patch will not be accepted, and it is not meant against you personally. Simply correct all issues raised against your patch and resend it. Differences between the kernel community and corporate structuresThe kernel community works differently than most traditional corporate development environments. Here are a list of things that you can try to do to try to avoid problems: Good things to say regarding your proposed changes:
Bad things you should avoid saying:
Another way the kernel community is different than most traditional software engineering work environments is the faceless nature of interaction. One benefit of using email and irc as the primary forms of communication is the lack of discrimination based on gender or race. The Linux kernel work environment is accepting of women and minorities because all you are is an email address. The international aspect also helps to level the playing field because you can't guess gender based on a person's name. A man may be named Andrea and a woman may be named Pat. Most women who have worked in the Linux kernel and have expressed an opinion have had positive experiences. The language barrier can cause problems for some people who are not comfortable with English. A good grasp of the language can be needed in order to get ideas across properly on mailing lists, so it is recommended that you check your emails to make sure they make sense in English before sending them. Break up your changesThe Linux kernel community does not gladly accept large chunks of code dropped on it all at once. The changes need to be properly introduced, discussed, and broken up into tiny, individual portions. This is almost the exact opposite of what companies are used to doing. Your proposal should also be introduced very early in the development process, so that you can receive feedback on what you are doing. It also lets the community feel that you are working with them, and not simply using them as a dumping ground for your feature. However, don't send 50 emails at one time to a mailing list, your patch series should be smaller than that almost all of the time. The reasons for breaking things up are the following:
Here is an analogy from kernel developer Al Viro:
Also realize that it is not acceptable to send patches for inclusion that are unfinished and will be "fixed up later." Justify your changeAlong with breaking up your patches, it is very important for you to let the Linux community know why they should add this change. New features must be justified as being needed and useful. Document your changeWhen sending in your patches, pay special attention to what you say in the text in your email. This information will become the ChangeLog information for the patch, and will be preserved for everyone to see for all time. It should describe the patch completely, containing:
For more details on what this should all look like, please see the ChangeLog section of the document:
All of these things are sometimes very hard to do. It can take years to perfect these practices (if at all). It's a continuous process of improvement that requires a lot of patience and determination. But don't give up, it's possible. Many have done it before, and each had to start exactly where you are now. Thanks to Paolo Ciarrocchi who allowed the "Development Process" section to be based on text he had written, and to Randy Dunlap and Gerrit Huizenga for some of the list of things you should and should not say. Also thanks to Pat Mochel, Hanna Linder, Randy Dunlap, Kay Sievers, Vojtech Pavlik, Jan Kara, Josh Boyer, Kees Cook, Andrew Morton, Andi Kleen, Vadim Lobanov, Jesper Juhl, Adrian Bunk, Keri Harris, Frans Pop, David A. Wheeler, Junio Hamano, Michael Kerrisk, and Alex Shepard for their review, comments, and contributions. Without their help, this document would not have been possible. Maintainer: Greg Kroah-Hartman greg@kroah.com posted Thu, 17 Nov 2005 in [/linux] |
|
My Linux Stuff RSS |
|
||