Back to home page

OSCL-LXR

 
 

    


0001 .. _development_early_stage:
0002 
0003 Early-stage planning
0004 ====================
0005 
0006 When contemplating a Linux kernel development project, it can be tempting
0007 to jump right in and start coding.  As with any significant project,
0008 though, much of the groundwork for success is best laid before the first
0009 line of code is written.  Some time spent in early planning and
0010 communication can save far more time later on.
0011 
0012 
0013 Specifying the problem
0014 ----------------------
0015 
0016 Like any engineering project, a successful kernel enhancement starts with a
0017 clear description of the problem to be solved.  In some cases, this step is
0018 easy: when a driver is needed for a specific piece of hardware, for
0019 example.  In others, though, it is tempting to confuse the real problem
0020 with the proposed solution, and that can lead to difficulties.
0021 
0022 Consider an example: some years ago, developers working with Linux audio
0023 sought a way to run applications without dropouts or other artifacts caused
0024 by excessive latency in the system.  The solution they arrived at was a
0025 kernel module intended to hook into the Linux Security Module (LSM)
0026 framework; this module could be configured to give specific applications
0027 access to the realtime scheduler.  This module was implemented and sent to
0028 the linux-kernel mailing list, where it immediately ran into problems.
0029 
0030 To the audio developers, this security module was sufficient to solve their
0031 immediate problem.  To the wider kernel community, though, it was seen as a
0032 misuse of the LSM framework (which is not intended to confer privileges
0033 onto processes which they would not otherwise have) and a risk to system
0034 stability.  Their preferred solutions involved realtime scheduling access
0035 via the rlimit mechanism for the short term, and ongoing latency reduction
0036 work in the long term.
0037 
0038 The audio community, however, could not see past the particular solution
0039 they had implemented; they were unwilling to accept alternatives.  The
0040 resulting disagreement left those developers feeling disillusioned with the
0041 entire kernel development process; one of them went back to an audio list
0042 and posted this:
0043 
0044         There are a number of very good Linux kernel developers, but they
0045         tend to get outshouted by a large crowd of arrogant fools. Trying
0046         to communicate user requirements to these people is a waste of
0047         time. They are much too "intelligent" to listen to lesser mortals.
0048 
0049 (https://lwn.net/Articles/131776/).
0050 
0051 The reality of the situation was different; the kernel developers were far
0052 more concerned about system stability, long-term maintenance, and finding
0053 the right solution to the problem than they were with a specific module.
0054 The moral of the story is to focus on the problem - not a specific solution
0055 - and to discuss it with the development community before investing in the
0056 creation of a body of code.
0057 
0058 So, when contemplating a kernel development project, one should obtain
0059 answers to a short set of questions:
0060 
0061  - What, exactly, is the problem which needs to be solved?
0062 
0063  - Who are the users affected by this problem?  Which use cases should the
0064    solution address?
0065 
0066  - How does the kernel fall short in addressing that problem now?
0067 
0068 Only then does it make sense to start considering possible solutions.
0069 
0070 
0071 Early discussion
0072 ----------------
0073 
0074 When planning a kernel development project, it makes great sense to hold
0075 discussions with the community before launching into implementation.  Early
0076 communication can save time and trouble in a number of ways:
0077 
0078  - It may well be that the problem is addressed by the kernel in ways which
0079    you have not understood.  The Linux kernel is large and has a number of
0080    features and capabilities which are not immediately obvious.  Not all
0081    kernel capabilities are documented as well as one might like, and it is
0082    easy to miss things.  Your author has seen the posting of a complete
0083    driver which duplicated an existing driver that the new author had been
0084    unaware of.  Code which reinvents existing wheels is not only wasteful;
0085    it will also not be accepted into the mainline kernel.
0086 
0087  - There may be elements of the proposed solution which will not be
0088    acceptable for mainline merging.  It is better to find out about
0089    problems like this before writing the code.
0090 
0091  - It's entirely possible that other developers have thought about the
0092    problem; they may have ideas for a better solution, and may be willing
0093    to help in the creation of that solution.
0094 
0095 Years of experience with the kernel development community have taught a
0096 clear lesson: kernel code which is designed and developed behind closed
0097 doors invariably has problems which are only revealed when the code is
0098 released into the community.  Sometimes these problems are severe,
0099 requiring months or years of effort before the code can be brought up to
0100 the kernel community's standards.  Some examples include:
0101 
0102  - The Devicescape network stack was designed and implemented for
0103    single-processor systems.  It could not be merged into the mainline
0104    until it was made suitable for multiprocessor systems.  Retrofitting
0105    locking and such into code is a difficult task; as a result, the merging
0106    of this code (now called mac80211) was delayed for over a year.
0107 
0108  - The Reiser4 filesystem included a number of capabilities which, in the
0109    core kernel developers' opinion, should have been implemented in the
0110    virtual filesystem layer instead.  It also included features which could
0111    not easily be implemented without exposing the system to user-caused
0112    deadlocks.  The late revelation of these problems - and refusal to
0113    address some of them - has caused Reiser4 to stay out of the mainline
0114    kernel.
0115 
0116  - The AppArmor security module made use of internal virtual filesystem
0117    data structures in ways which were considered to be unsafe and
0118    unreliable.  This concern (among others) kept AppArmor out of the
0119    mainline for years.
0120 
0121 In each of these cases, a great deal of pain and extra work could have been
0122 avoided with some early discussion with the kernel developers.
0123 
0124 
0125 Who do you talk to?
0126 -------------------
0127 
0128 When developers decide to take their plans public, the next question will
0129 be: where do we start?  The answer is to find the right mailing list(s) and
0130 the right maintainer.  For mailing lists, the best approach is to look in
0131 the MAINTAINERS file for a relevant place to post.  If there is a suitable
0132 subsystem list, posting there is often preferable to posting on
0133 linux-kernel; you are more likely to reach developers with expertise in the
0134 relevant subsystem and the environment may be more supportive.
0135 
0136 Finding maintainers can be a bit harder.  Again, the MAINTAINERS file is
0137 the place to start.  That file tends to not always be up to date, though,
0138 and not all subsystems are represented there.  The person listed in the
0139 MAINTAINERS file may, in fact, not be the person who is actually acting in
0140 that role currently.  So, when there is doubt about who to contact, a
0141 useful trick is to use git (and "git log" in particular) to see who is
0142 currently active within the subsystem of interest.  Look at who is writing
0143 patches, and who, if anybody, is attaching Signed-off-by lines to those
0144 patches.  Those are the people who will be best placed to help with a new
0145 development project.
0146 
0147 The task of finding the right maintainer is sometimes challenging enough
0148 that the kernel developers have added a script to ease the process:
0149 
0150 ::
0151 
0152         .../scripts/get_maintainer.pl
0153 
0154 This script will return the current maintainer(s) for a given file or
0155 directory when given the "-f" option.  If passed a patch on the
0156 command line, it will list the maintainers who should probably receive
0157 copies of the patch.  This is the preferred way (unlike "-f" option) to get the
0158 list of people to Cc for your patches.  There are a number of options
0159 regulating how hard get_maintainer.pl will search for maintainers; please be
0160 careful about using the more aggressive options as you may end up including
0161 developers who have no real interest in the code you are modifying.
0162 
0163 If all else fails, talking to Andrew Morton can be an effective way to
0164 track down a maintainer for a specific piece of code.
0165 
0166 
0167 When to post?
0168 -------------
0169 
0170 If possible, posting your plans during the early stages can only be
0171 helpful.  Describe the problem being solved and any plans that have been
0172 made on how the implementation will be done.  Any information you can
0173 provide can help the development community provide useful input on the
0174 project.
0175 
0176 One discouraging thing which can happen at this stage is not a hostile
0177 reaction, but, instead, little or no reaction at all.  The sad truth of the
0178 matter is (1) kernel developers tend to be busy, (2) there is no shortage
0179 of people with grand plans and little code (or even prospect of code) to
0180 back them up, and (3) nobody is obligated to review or comment on ideas
0181 posted by others.  Beyond that, high-level designs often hide problems
0182 which are only revealed when somebody actually tries to implement those
0183 designs; for that reason, kernel developers would rather see the code.
0184 
0185 If a request-for-comments posting yields little in the way of comments, do
0186 not assume that it means there is no interest in the project.
0187 Unfortunately, you also cannot assume that there are no problems with your
0188 idea.  The best thing to do in this situation is to proceed, keeping the
0189 community informed as you go.
0190 
0191 
0192 Getting official buy-in
0193 -----------------------
0194 
0195 If your work is being done in a corporate environment - as most Linux
0196 kernel work is - you must, obviously, have permission from suitably
0197 empowered managers before you can post your company's plans or code to a
0198 public mailing list.  The posting of code which has not been cleared for
0199 release under a GPL-compatible license can be especially problematic; the
0200 sooner that a company's management and legal staff can agree on the posting
0201 of a kernel development project, the better off everybody involved will be.
0202 
0203 Some readers may be thinking at this point that their kernel work is
0204 intended to support a product which does not yet have an officially
0205 acknowledged existence.  Revealing their employer's plans on a public
0206 mailing list may not be a viable option.  In cases like this, it is worth
0207 considering whether the secrecy is really necessary; there is often no real
0208 need to keep development plans behind closed doors.
0209 
0210 That said, there are also cases where a company legitimately cannot
0211 disclose its plans early in the development process.  Companies with
0212 experienced kernel developers may choose to proceed in an open-loop manner
0213 on the assumption that they will be able to avoid serious integration
0214 problems later.  For companies without that sort of in-house expertise, the
0215 best option is often to hire an outside developer to review the plans under
0216 a non-disclosure agreement.  The Linux Foundation operates an NDA program
0217 designed to help with this sort of situation; more information can be found
0218 at:
0219 
0220     https://www.linuxfoundation.org/nda/
0221 
0222 This kind of review is often enough to avoid serious problems later on
0223 without requiring public disclosure of the project.