2022年Linux内核开发报告 .pdf
? The Linux FoundationA White Paper By The Linux Foundationhttp:/www.linuxfoundation.orgLinux Kernel DevelopmentHow Fast it is Going, Who is Doing It, What They are Doing, and Who is Sponsoring ItDecember 2010.Jonathan Corbet, LWN.netGreg Kroah-Hartman, SuSE Labs / Novell Inc.Amanda McPherson, The Linux Foundation名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 20 页 - - - - - - - - - 1796 18th Street, Suite CSan Francisco, CA 94107+1 415 723 9709http:/www.linuxfoundation.orgcompliancelinuxfoundation.org.1Linux Kernel DevelopmentSummaryThe kernel which forms the core of the Linux system is the result of one of the largest cooperative software projects ever attempted. Regular 2-3 month releases deliver stable updates to Linux users, each with significant new features, added device support, and improved performance. The rate of change in the kernel is high and increasing, with approximately 10,000 patches going into each recent kernel release. These releases each contain the work of over 1000 developers representing around 200 corporations.Since 2005, over 6100 individual developers from over 600 different companies have contributed to the kernel. The Linux kernel, thus, has become a common resource developed on a massive scale by companies which are fierce competitors in other areas.The first version of this study was published in 2008; it was then updated in 2009. That update noted a number of changes, including a 10% increase in the number of developers participating in each release cycle, a notable increase in the number of companies participating, and a tripling of the rate at which code is being added to the kernel. At that time, all of the numbers were in a period of rapid increase.As documented in the last paper, in 2009 the Linux community saw, with the release of 2.6.30, a peak in the lines of code added. This can largely be attributed to significant new features being added to the kernel, most notably the first additions of Btrfs, perf and ftrace, as well as the peak of the inflow from the Linux-staging tree that had been happening for some time.This update shows a slightly different picture. The number of commits peaked with the 2.6.30 release; the number of commits for 2.6.35 was 18% lower. Most other metrics have fallen as well.In short, we see a step back from the frenzied activity of 2.6.30 even though the number of developers involved has fallen only slightly since its peak in 2.6.32.The numbers in this edition of the paper reflect the natural development cycle of an operating system that had major pieces added/changed in the previous year. Of course the Linux kernel community is still hard at work and growing. In fact, there have been 1.5 million lines of code added to the kernel since the 2009 update. Since the last paper, additions and changes translate to an amazing 9,058 lines added, 4,495 lines removed, and 1,978 lines changed every day - weekends and holidays included.The data in this year s update also shows a good showing of new players in the Linux kernel development space from the world of mobile/consumer electronics and embedded technology (and their suppliers). This is a healthy development and not surprising given the growth of Linux usage in embedded devices, even though the authors would like to see more companies from that space participate in the Linux development community.The overall picture shows a robust development community which continues to grow both in size and in productivity. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 20 页 - - - - - - - - - 1796 18th Street, Suite CSan Francisco, CA 94107+1 415 723 9709http:/www.linuxfoundation.orgcompliancelinuxfoundation.org.2Linux Kernel DevelopmentIntroductionThe Linux kernel is the lowest level of software running on a Linux system. It is charged with managing the hardware, running user programs, and maintaining the overall security and integrity of the whole system. It is this kernel which, after its initial release by Linus Torvalds in 1991, jump-started the development of Linux as a whole. The kernel is a relatively small part of the software on a full Linux system (many other large components come from the GNU project, the GNOME and KDE desktop projects, the X.org project, and many other sources), but it is the core which determines how well the system will work and is the piece which is truly unique to Linux.The Linux kernel is an interesting project to study for a number of reasons. It is one of the largest individual components on almost any Linux system. It also features one of the fastest-moving development processes and involves more developers than any other open source project. Since 2005, kernel development history is also quite well documented, thanks to the use of the Git source code management system.This paper takes advantage of that development history to look at how the process works, focusing on over five years of kernel history as represented by the 2.6.11 through 2.6.35 releases. This is the third version of this paper, following up on http:/www.linuxfoundation.org/sites/main/files/publications/linuxkerneldevelopment.pdf the original study which was published in April, 2008, and http:/www.linuxfoundation.org/sites/main/files/publications/whowriteslinux.pdf the 2009 update, which looked at the history through the 2.6.30 release. A look at the five kernel releases which have happened since then shows that, while many things remain the same, others are changing.Development ModelLinux kernel development proceeds under a loose, time-based release model, with a new major kernel release occurring every 2-3 months. This model, which was first formalized in 2005, gets new features into the mainline kernel and out to users with a minimum of delay. That, in turn, speeds the pace of development and minimizes the number of external changes that distributors need to apply. As a result, distributor kernels contain relatively few distribution-specific changes; this leads to higher quality and fewer differences between distributions.One significant change since the initial version of this paper is the establishment of the linux-next tree. Linux-next serves as a staging area for the next kernel development cycle; as of this writing, 2.6.36 is in the stabilization phase, so linux-next contains changes intended for 2.6.37. This repository gives developers a better view of which changes are coming in the future and helps them to ensure that there will be a minimum of integration problems when the next development cycle begins. Linux-next smooths out the development cycle, helping it to scale to higher rates of change.After each mainline 2.6 release, the kernel s “ stable team” (currently Greg Kroah-Hartman) takes up short-term maintenance, applying important fixes as they are developed. The stable process 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 20 页 - - - - - - - - - 1796 18th Street, Suite CSan Francisco, CA 94107+1 415 723 9709http:/www.linuxfoundation.orgcompliancelinuxfoundation.org.3Linux Kernel Developmentensures that important fixes are made available to distributors and users and that they are incorporated into future mainline releases as well. The stable maintenance period lasts a minimum of one development cycle and, for specific kernel releases, can go significantly longer; some stable update statistics will be provided below.Release FrequencyThe desired release period for a major kernel release is, by common consensus, 8-12 weeks. A much-shorter period would not give testers enough times to find problems with new kernels, while a longer period would allow too much work to pile up between releases. The actual time between kernel releases tends to vary a bit, depending on the size of the release and the difficulty encountered in tracking down the last regressions. Since 2.6.11, the actual kernel release history looks like:Kernel VersionRelease DateDays of Development2.6.112005-03-02692.6.122005-05-171082.6.132005-08-28732.6.142005-10-27612.6.15 2006-01-02682.6.16 2006-03-19772.6.172006-06-17912.6.18 2006-09-19952.6.19 2006-11-29722.6.202007-02-04682.6.212007-04-25812.6.22 2007-07-08752.6.232007-10-09942.6.24 2008-01-241082.6.25 2008-04-16832.6.26 2008-07-13882.6.272008-10-09882.6.282008-12-24762.6.292009-03-23892.6.30 2009-06-09 782.6.312009-09-09922.6.322009-12-02842.6.332010-02-24842.6.342010-05-15812.6.352010-08-0177The average kernel development cycle currently runs for 81 days, just under twelve weeks.名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 20 页 - - - - - - - - - 1796 18th Street, Suite CSan Francisco, CA 94107+1 415 723 9709http:/www.linuxfoundation.orgcompliancelinuxfoundation.org.4Linux Kernel DevelopmentRate of ChangeWhen preparing work for submission to the Linux kernel, developers break their changes down into small, individual units, called patches. These patches usually do only one thing to the source code; they are built on top of each other, modifying the source code by changing, adding, or removing lines of code. Each patch should, when applied, yield a kernel which still builds and works properly. This discipline forces kernel developers to break their changes down into small, logical pieces; as a result, each change can be reviewed for code quality and correctness. One other result is that the number of individual changes that go into each kernel release is very large, as can be seen in the table below:Kernel VersionChanges (Patches)2.6.113,6162.6.125,0472.6.133,9042.6.143,6272.6.154,9592.6.16 5,3692.6.175,7272.6.186,3232.6.196,6852.6.204,7682.6.215,0162.6.226,5262.6.236,6622.6.249,8362.6.2512,2432.6.269,9412.6.2710,6282.6.28 9,0482.6.2911,6782.6.3011,9892.6.3110,8832.6.3210,9892.6.3310,8712.6.349,4432.6.359,801名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 20 页 - - - - - - - - - 1796 18th Street, Suite CSan Francisco, CA 94107+1 415 723 9709http:/www.linuxfoundation.orgcompliancelinuxfoundation.org.5Linux Kernel DevelopmentChanges to the Kernel Over TimeBy taking into account the amount of time required for each kernel release, one can arrive at the number of changes accepted into the kernel per hour. The results can be seen in this table:Kernel VersionChanges Per Hour2.6.112.182.6.121.952.6.132.232.6.142.482.6.153.042.6.162.912.6.172.622.6.182.222.6.193.872.6.202.922.6.212.582.6.223.632.6.232.952.6.243.792.6.256.152.6.264.712.6.275.032.6.284.962.6.295.47140001200010000800060004000200002.6.11 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.18 2.6.19 2.6.20 2.6.21 2.6.22 2.6.23 2.6.24 2.6.25 2.6.26 2.6.27 2.6.28 2.6.29 2.6.30 2.6.31 2.6.32 2.6.33 2.6.34 2.6.35Changes (Patches)Kernel Version名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 20 页 - - - - - - - - - 1796 18th Street, Suite CSan Francisco, CA 94107+1 415 723 9709http:/www.linuxfoundation.orgcompliancelinuxfoundation.org.6Linux Kernel DevelopmentKernel VersionChanges Per Hour2.6.306.402.6.314.932.6.325.462.6.335.392.6.344.862.6.355.30So, between the 2.6.11 and 2.6.35 kernel releases (which were 1902 days apart), there were, on average, 4.02 patches applied to the kernel tree per hour. In the time since the publication of the previous version of this paper, that rate has been significantly higher: 5.18 patches per hour. As the Linux kernel grows, the rate of change is growing with it.The rate of change has slowed slightly from the rate (5.45 patches/hour) reported in the 2009 update; the peak rate seen with the 2.6.30 kernel release has not been repeated. Development rates are naturally variable, and the rates for the kernel have never increased in a monotonic fashion; that said, the rate of change has remained notably lower for the last year. There are a couple of explanations for that trend:The kernels since 2.6.30 have seen the completion and stabilization of a number of long-term projects, including the ext4 and btrfs filesystems, the addition of the ftrace and perf events subsystems, and the reimplementation of our graphics layer. Rates of change will naturally slow as the finishing touches are put on these developments.The addition of the staging tree in 2.6.28 began a process of merging a large amount of out-of-tree code into the mainline kernel. By the 2.6.31 development cycle, that process was slowing down as the backlog of code was taken care of. There are still new drivers entering the kernel via the staging tree, but they are now arriving at a rate which more closely reflects the actual rate of development.The burst of activity caused by the staging tree is not likely to be repeated anytime soon, but the pace of kernel development as a whole can be expected to increase as developers take on new challenges in the future.It is also worth noting that the above figures understate the total level of activity; most patches go through a number of revisions before being accepted into the mainline kernel, and many are never accepted at all. The ability to sustain this rate of change for years is unprecedented in any previous public software project.Stable UpdatesAs mentioned toward the beginning of this document, kernel development does not stop with a mainline release. Inevitably, problems will be found in released kernels, and patches will be made to fix those problems. The stable kernel update process was designed to capture those patches in a way that ensures that both the mainline kernel and current releases are fixed. These stable 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 20 页 - - - - - - - - - 1796 18th Street, Suite CSan Francisco, CA 94107+1 415 723 9709http:/www.linuxfoundation.orgcompliancelinuxfoundation.org.7Linux Kernel Developmentupdates are the base from which most distributor kernels are made.The stable kernel update history (since the stable kernel process was introduced after the 2.6.11 release) looks like this:Kernel VersionTotal UpdatesFixes2.6.1112792.6.126532.6.135442.6.147962.6.1571102.6.166210532.6.17141912.6.1882402.6.1971892.6.20214472.6.2171622.6.22193792.6.23163022.6.2472462.6.25204922.6.2683212.6.275315532.6.28106132.6.2963832.6.30104192.6.31148262.6.322117932.6.3378832.6.3476012.6.354228As can be seen, the number of updates going into stable kernels has grown over the years. The main driver for this increase is a much higher level of discipline in the development community: we have gotten much better at evaluating patches and identifying those which are applicable to releaased kernels. Additionally, some kernels are receiving stable updates for relatively long periods of time; the 2.6.27 kernel is still being updated as of this writing.With just over five years of history, the stable update series has proven its value by allowing the final fixes to be made to released kernels while, simultaneously, letting mainline development