Home Linux KernelLinux Kernel 7.2 Hits 43 Million Lines: Verified with 4 Code Counters

Linux Kernel 7.2 Hits 43 Million Lines: Verified with 4 Code Counters

By sk
13 views 11 mins read

The Linux kernel has reached another major milestone. The latest Linux 7.2 development tree now contains approximately 42.6 million lines of source code, comments, and blank lines combined. This data is verified independently by both tokei and scc on the official v7.2-rc1 tag. That makes it the largest Linux kernel source tree ever measured.

At first glance, that number may seem huge. However, it does not mean Linux has become bloated. Instead, it shows how much hardware Linux supports today and how actively the kernel continues to evolve.

Let's look at what changed.

Linux 7.2 Breaks the 42 Million Line Mark

The Linux 7.2-rc1 Git tree was measured using multiple code-counting tools on the exact v7.2-rc1 tag commit (dc59e4fea9d8).

ostechnix@fedora:~/linux$  git log --oneline -1
dc59e4fea9d8 (HEAD -> master, tag: v7.2-rc1, origin/master, origin/HEAD) Linux 7.2-rc1

Here is what each tool found:

ToolFilesTotal LinesCode LinesCommentsBlanks
cloc82,30940,416,24230,509,9814,840,4695,065,792
tokei89,04242,584,52632,359,8964,893,1475,331,483
scc88,98842,582,36732,451,0894,807,5735,323,705
wc -l (all files)43,179,595

Our own measurements show that tokei and scc agree almost exactly at about 42.58 million total lines for Linux v7.2-rc1. In contrast, cloc v2.08 reports about 40.42 million lines, roughly 2.16 million fewer. Investigation shows that cloc v2.08 does not count the kernel's Device Tree (.dts/.dtsi) source files. The Linux v7.2-rc1 tree contains 6,347 such files, and both tokei and scc count 2,095,900 lines in them, accounting for nearly 97% of the difference.

The wc -l all-files count of 43,179,595 is where the "43 million" headline comes from. The ~597,000 line gap between that and the tokei/scc figure represents firmware blobs, compiled .dtb binaries, certificates, and other non-text files that no source counter should include. So the headline is technically accurate, just not a source-code measurement.

For comparison, Linux 7.1 contained approximately 42.1 million lines. The kernel gained roughly half a million additional lines during a single development cycle.

Although that sounds dramatic, the increase is expected. Thousands of developers contribute to Linux every release, and they support an enormous range of hardware. If you're not aware, over 2,000 developers worked on Linux Kernel 7.1, including more than 300 people who contributed for the first time.

Linux Keeps Growing Even After Removing Old Code

One surprising part of this milestone is that Linux grew despite removing legacy code.

Linux 7.1 started the process of dropping support for Intel's i486 processors, removing over 140,000 lines of legacy code including old PCMCIA host controllers and ISDN drivers. Linux 7.2 continues that cleanup by removing more i486-related code along with several obsolete drivers and legacy x86 components.

In other words, developers continue to remove outdated code while adding support for today's hardware. That balance helps keep the kernel modern without carrying unnecessary maintenance work forever.

Why Is the Linux Kernel So Large?

The answer is Drivers.

The Linux kernel supports an incredible variety of hardware. Every graphics card, storage controller, network adapter, laptop feature, USB device, and embedded platform needs kernel support.

As new hardware reaches the market, developers add new drivers while maintaining compatibility with existing devices. Because of that, most of the kernel's growth comes from hardware support rather than the kernel's core scheduling or memory-management code.

AMDGPU Remains the Largest Driver

The biggest contributor is still the AMD graphics subsystem.

The combined AMDGPU and AMDKFD driver contains about 6,356,056 lines of code, making it the largest driver in the entire Linux kernel.

Linus Torvalds has pointed out that roughly one-third of one large pull request consisted of AMD GPU register definition files. Those files are mostly generated data that helps Linux communicate with modern AMD graphics hardware. Even if those generated files are ignored, device drivers still account for most of the kernel's growth.

Bigger Doesn't Mean Slower

Many people assume that more lines of code automatically mean slower software. That is not how the Linux kernel works.

Most of the additional code exists to support hardware that many users will never own. Much of it lives in loadable modules that only activate when the corresponding hardware is present. As a result, the kernel continues to improve while expanding hardware compatibility across desktops, servers, laptops, embedded systems, cloud platforms, and supercomputers.

Count the Total Number of Lines in Linux Kernel Code

Anyone can clone the Linux kernel repository and measure it. First, get the source:

# Full clone (~5 GB) — use --depth=1 for a shallow clone (~1.5 GB)
git clone --depth=1 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux

Method 1: cloc (The widely cited reference tool)

Cloc is the most commonly referenced tool for kernel line counts, but note that it undercounts the Linux kernel by ~2 million lines because it does not recognize Device Tree source files.

# Install
sudo apt install cloc # Debian/Ubuntu
sudo dnf install cloc # Fedora/RHEL
sudo pacman -S cloc # Arch

# Run
cloc --progress=1 .

# To measure only the AMD graphics driver:
cloc drivers/gpu/drm/amd

cloc can take ~15 minutes on the full tree.

Count the Total Number of Lines in Linux Kernel Code using Cloc Utility
Count the Total Number of Lines in Linux Kernel Code using Cloc Utility

Method 2: tokei (Faster and more accurate. Recommended)

tokei is significantly faster than cloc and correctly counts Device Tree files, making it the more accurate choice for the Linux kernel.

# Install
cargo install tokei
# or: sudo apt install tokei / brew install tokei

tokei .

Sample Output:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Language Files Lines Code Comments Blanks
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
AWK 13 2805 1923 500 382
Alex 4 662 547 0 115
ASN.1 15 656 441 87 128
Assembly 11 5781 5445 0 336
GNU Style Assembly 1337 371255 270423 56888 43944
Autoconf 6 459 395 30 34
Automake 3 31 23 3 5
BASH 62 3038 2094 437 507
Bazel 81 1829 1474 54 301
Bitbake 3 13 4 6 3
C 36910 26320472 19615926 2909605 3794941
C Header 26813 10822880 8416361 1615212 791307
C++ 7 2291 1969 81 241
C++ Header 2 125 59 55 11
CSS 4 411 244 97 70
Device Tree 6343 2097441 1724154 92401 280886
Forge Config 15 1352 321 744 287
Gherkin (Cucumber) 1 336 199 97 40
Happy 10 6013 5290 0 723
HEX 2 173 173 0 0
INI 2 13 6 5 2
Jinja2 149 1187 966 145 76
JSON 1043 607008 607006 0 2
Lex 10 2940 2218 356 366
LD Script 13 552 427 40 85
Makefile 3203 87274 60667 13531 13076
Module-Definition 2 157 137 0 20
Objective-C 1 89 72 0 17
Pacman's makepkg 1 134 91 13 30
Perl 61 43189 33862 4009 5318
PO File 7 6711 3346 2259 1106
Python 439 130209 102002 8291 19916
RPM Specfile 1 215 174 14 27
ReStructuredText 4011 820556 622655 0 197901
Ruby 1 29 25 0 4
Shell 1172 219683 153221 27411 39051
Snakemake 5 153 125 13 15
SVG 87 57503 56094 1311 98
SWIG 1 252 154 27 71
TeX 1 234 155 73 6
Plain Text 981 109702 0 89924 19778
TOML 3 57 36 12 9
Unreal Script 5 618 371 156 91
Apache Velocity 1 15 15 0 0
Vim Script 1 42 33 6 3
XSL 10 200 122 52 26
XML 32 26269 23572 1452 1245
YAML 5673 648526 529448 23888 95190
─────────────────────────────────────────────────────────────────────────────────
HTML 2 29 25 0 4
|- JavaScript 1 7 7 0 0
(Total) 36 32 0 4
─────────────────────────────────────────────────────────────────────────────────
Markdown 9 534 0 385 149
|- BASH 1 2 2 0 0
|- C 1 20 12 6 2
|- Rust 1 98 76 13 9
|- YAML 1 25 22 0 3
(Total) 679 112 404 163
─────────────────────────────────────────────────────────────────────────────────
Rust 473 143187 114374 13573 15240
|- Markdown 351 39084 913 29885 8286
(Total) 182271 115287 43458 23526
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total 89042 42584526 32359896 4893147 5331483
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Finishes in under a minute and matches scc results closely (See the next section).

Method 3: scc (Fastest, with complexity metrics)

scc matches tokei's accuracy and additionally reports cyclomatic complexity per language, useful for understanding which parts of the kernel are hardest to maintain.

# Install (download binary from GitHub releases, or:)
go install github.com/boyter/scc/v3@latest

scc .

Sample Output:

───────────────────────────────────────────────────────────────────────────────
Language            Files       Lines    Blanks  Comments       Code Complexity
───────────────────────────────────────────────────────────────────────────────
C                  36,910  26,320,472 3,795,058 2,909,421 19,615,993  2,566,279
C Header           26,813  10,822,880   791,303 1,614,799  8,416,778     66,444
Device Tree         6,343   2,097,441   280,886    92,367  1,724,188         36
YAML                5,672     648,427   104,949    25,934    517,544          0
ReStructuredTe…     4,011     820,556   197,878         0    622,678          0
Makefile            3,203      87,274    13,076    13,531     60,667        464
Assembly            1,348     377,036    41,691    49,680    285,665      3,505
Shell               1,174     220,250    37,034    26,897    156,319     12,925
JSON                1,043     607,008         2         0    607,006          0
Plain Text            981     109,702    19,777         0     89,925          0
Rust                  473     182,419    15,156    52,407    114,856     10,808
Python                439     130,209    15,774    13,048    101,387     15,323
Jinja                 149       1,187        76       145        966        193
SVG                    87      57,503        98     1,311     56,094          2
Perl                   67      46,073     6,048     4,183     35,842      5,246
BASH                   63       3,399       513       413      2,473        324
DOT                    36       1,261        81        62      1,118          0
XML                    32      26,269     1,465     1,755     23,049          0
AWK                    17       3,102       311       232      2,559        532
CSV                    11       1,539       126         0      1,413          0
Extensible Sty…        10         200        26         0        174          0
Happy                  10       6,013       723         0      5,290          0
LEX                    10       2,940       366       355      2,219          0
Markdown                9         679       162         0        517          0
LD Script               8         390        60        29        301          0
C++                     7       2,291       241        81      1,969        332
Autoconf                6         459        34        30        395         11
License                 5         422        84         0        338          0
Snakemake               5         153        15        13        125          0
Unreal Script           5         618        91       156        371         21
Alex                    4         662       115         0        547          0
CSS                     4         411        70        97        244          0
Raku                    3         213        19        21        173         33
Systemd                 3         167        25        63         79          0
TOML                    3          57         8        12         37          0
Bazel                   2         777       167       177        433          6
C++ Header              2         125        11        55         59          2
HEX                     2         173         0         0        173          0
HTML                    2          34         4         5         25          0
INI                     2          13         2         5          6          0
Module-Definit…         2         157        20         0        137          4
bait                    2          64         4        15         45          9
sed                     2         106        23        53         30          0
CloudFormation…         1          99        17         2         80          0
Gherkin Specif…         1         336        40        97        199          0
MATLAB                  1          89        17        37         35          3
Ruby                    1          29         4         0         25          1
Scallop                 1           3         0         0          3          0
TeX                     1         234         6        73        155          0
Vim Script              1          42         3        12         27          5
XML Schema              1         404        46         0        358          0
───────────────────────────────────────────────────────────────────────────────
Total              88,988  42,582,367 5,323,705 4,807,573 32,451,089  2,682,508
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop (organic) $1,473,621,894
Estimated Schedule Effort (organic) 219.99 months
Estimated People Required (organic) 595.12
───────────────────────────────────────────────────────────────────────────────
Processed 1595970277 bytes, 1595.970 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────

On the v7.2-rc1 tree, scc also estimates the cost to develop the kernel from scratch at approximately $1.47 billion using the COCOMO organic model, a rough but striking number.

Method 4: wc -l (Quick all-files sanity check)

This counts every line in every file regardless of type, so it includes binaries and firmware blobs. It produces the highest number and is not a substitute for a proper code counter, but useful for a rough upper bound.

find . -not -path './.git/*' -type f \
| xargs wc -l 2>/dev/null \
| awk '/total/{sum += $1} END{print sum}'

Sample Output:

43179595

Note: Do not use | tail -1 at the end. When there are tens of thousands of files, xargs splits them into multiple batches and each batch prints its own total line. tail -1 only captures the last batch's subtotal, producing a wildly incorrect result.

Tool Comparison

ToolSpeedLanguage-awareNotes
wc -lFastestCounts all files including binaries
tokeiVery fastBest balance of speed and accuracy
sccFastAlso reports cyclomatic complexity
clocSlow (15–30m)Misses Device Tree files; undercounts kernel

Linux 7.2 Code Statistics Summary

Measured on commit dc59e4fea9d8 (tag: v7.2-rc1), June 29, 2026:

StatisticValue
Total lines - all files (wc -l)43,179,595
Total lines - source-aware (tokei/scc)~42,583,000
Source code lines~32,400,000
Comment lines~4,850,000
Blank lines~5,327,000
Non-source files (gap)~597,000 lines (firmware blobs, compiled .dtb, certificates)
Largest driverAMDGPU + AMDKFD
AMD graphics driver~6,356,056 lines
Major source of growthDevice drivers
Legacy cleanupContinued removal of Intel i486 code and obsolete drivers
Estimated dev cost~$1.47 billion (COCOMO, via scc)

How the "43 million" headline is derived

Running wc -l across every file in the repository (including firmware blobs, compiled device tree binaries (.dtb), and certificates) gives 43,179,595 lines.

Source-aware tools like tokei and scc land at ~42.58 million because they correctly exclude those non-source files. The ~597,000 line gap between the two figures is exactly those binary and non-text files.

Conclusion

Crossing 42 million lines is more than a fun statistic. It reflects the scale of one of the world's largest collaborative software projects.

Linux kernel maintainers continue to add support for new hardware while removing code for platforms that have reached the end of their useful life. The result is a kernel that grows where it needs to and becomes cleaner where it can.

For Linux enthusiasts, this milestone is another reminder of how quickly kernel development moves and how much work goes into supporting everything from tiny embedded boards to the world's fastest supercomputers.

Source:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More