1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
HOWTO do Linux kernel development
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.
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.
Intro
-----
So, 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 architectural-dependent
parts written in assembly. A good understanding of C is required to
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, if anything for reference:
"The C Programming Language" by Kernhigan and Ritchie [Prentice Hall]
"Practical C Programming" by Steve Oualline [O'Reilly]
"Programming the 80386" by Crawford and Gelsinger [Sybek]
"UNIX Systems for Modern Architectures" by Curt Schimmel [Addison Wesley]
The kernel is written using GNU C and the GNU toolchain. While it
adheres to the ISO C99 (??) standard, it uses a number of extensions
that are not featured in the standard. 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 (`info gcc`) for
some information on them."
Please remember that you are trying to learn how to work with the
existing development community. It is a very diverse group of people,
with very high standards for coding, style, and procedure. These
procedures have been created over time based on what they have found to
work best for such a large and geographically dispursed team. Try to
learn as much as possible about these procedures ahead of time, as they
are well documented, and not expect people to adapt to you, or your
company's way of doing things.
Legal Issues
------------
The 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.
Documentation
------------
The Linux kernel source tree has a huge range of documents that are
invaluable in learning how to interact with the kernel community. Here
is a list of files that are in the kernel source tree that are required
reading:
Documetation/CodingStyle
This describes the Linux kernel coding style, and some of the
rational behind it. The main point here is that we have a coding
style, and you can not ignore it.
Documentation/SubmittingPatches
Documentation/SubmittingDrivers
These files describe in explicit detail, the proper format of how
you need to create your change, what needs to be in your email, what
kind of email you should send, who to send it to, and everything
else you will need to learn in order to submit a change that will be
accepted into the main kernel source tree. If you do not follow
these rules, the odds of your patch being accepted are very low.
Documentation/stable_api_nonsense.txt
This file describes the rational behind why the Linux kernel does
not have a stable in-kernel api. If you want to try to come up with
a shim-layer for some subsystem, in order to make it easier to adapt
your existing code to Linux, or to try to mitigate the rapid change
within the Linux kernel source tree, this document describes why
such a proposal will fail.
Documentation/SecurityBugs
If you feel you have found a security problem in the Linux kernel,
please follow the steps in this document to help notify the kernel
developers, and help solve the issue.
Documentation/ManagementStyle
This document describes how the Linux kernel maintainers work. If
you are ever confused as to exactly why a maintainer is not doing
what you want them to, refer to this document to help understand how
they work, and how to make their lives easier.
Documentation/stable_kernel_rules.txt
This file describes the rules on how the stable kernel releases
happen, and what to do if you want to get a change into one of these
releases.
Documentation/kernel-docs.txt
A list of external documentation that pertains to kernel
development. Please consult this list, if you do not find what you
are looking for within the in-kernel documentation.
The kernel also has a large number of documents that can be
automatically generated from the source code itself. This includes a
full description of the in-kernel api, and rules on how to handle
locking properly. The documents will be created in the
Documentation/DocBook/ directory and can be generated as PDF,
Postscript, HTML, and man pages by running:
make pdfdocs
make psdocs
make htmldocs
make mandocs
respectively from the main kernel source directory.
Becoming A Kernel Developer
---------------------------
If you do not know anything about Linux kernel development, you should
look at the Linux KernelNewbies project:
http://kernelnewbies.org
It consists of a helpful mailing list, where you can ask almost any type
of basic kernel development question (make sure to search the archives
first, before asking something that has already been answered in the
past.) It also has a IRC channel that you can use to ask questions in
real-time, and a lot of helpful documentation that is useful for
learning about Linux kernel development.
The website has basic information about code organization, subsystems,
and current projects (both in-tree and out-of-tree). It also basic
logistical information, like compiling a kernel and applying a patch.
If you do not know where you want to start, but you want to look for
some task to start doing to join into the kernel development community,
go to the Linux Kernel Janitor's project:
http://janitor.kernelnewbies.org/
It is a great place to start. It describes a list of relatively simple
tasks that need to be cleaned up and fixed within the Linux kernel
source tree. Working with the developers in charge of this project, you
will learn the basics of getting your patch into the Linux kernel tree,
and possibly point you in the direction of what to go work on next, if
you do not already have an idea.
If you already have a chunk of code that you want to have go into the
kernel tree, but need some help getting it in the proper form, the
kernel-mentors project was created to help you out with this. It is a
mailing list, and can be found at:
http://selenic.com/mailman/listinfo/kernel-mentors
The development process
-----------------------
<TODO>
Mailing lists
-------------
As 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. Please use a search engine to find these archives if you wish
to research what has been discussed in the past.
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 here:
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/
Above all, please remember to show respect to other subscribers.
Working with the community
--------------------------
The 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:
- "This solves multiple problems."
- "This deletes 2000 lines of code."
- "Here is a patch that explains what I am trying to describe."
- "I tested it on 5 different architectures..."
- "Here is a series of small patches that..."
- "This increases performance on typical machines..."
Bad things you should avoid saying:
- "We did it this way in AIX/ptx/Solaris, so therefore it must be
good..."
- "I've being doing this for 20 years, so..."
- "It makes this proprietary benchmark go faster"
- "This is required for my company to make money"
- "This is for our Enterprise product line."
- "Here is my 1000 page design document that describes my idea"
- "I've been working on this for 6 months..."
- "Here's a 5000 line patch that..."
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.
Here is a group that is a good starting point for women interested in
contributing to Linux:
http://www.linuxchix.org/
Break your changes up
---------------------
The 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
exactly 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.
The reasons for breaking things up are the following:
1) Small patches increase the likelihood that your patches will be
applied, since they don't take much time or effort to verify for
correctness. A 5 line patch can be applied by a maintainer with
barely a second glance. But, a 500 line patch may take hours to
review for correctness (the time it takes is exponentially
proportional to the size of the patch, or something).
Small patches also make it very easy to debug when something goes
wrong. It's much easier to back out patches one by one, than it is
to dissect a very large patch after it's been applied (and broken
something).
2) It's important not only to send small patches, but also to rewrite
and simplify (or simply re-order) patches before submitting them.
Think of a teacher grading homework from a math student. The teacher
does not want to see the student's trials and errors before they came up
with the solution. They want to see the cleanest, most elegant answer.
The student knows this, and would never submit her intermediate work
before the final solution.
The same is true of kernel development. The maintainers and reviewers do
not want to see the thought process behind the solution to the problem
one is solving. They want to see a final, simple, elegant solution.
Both 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 Randy Dunlap and Gerrit Huizenga for the list of things you
should and should not say. Also to Pat Mochel for their review and
comments on early drafts of this document.
Maintainer: Greg Kroah-Hartman <greg@kroah.com>
|