The AMD Radeon Graphics Driver Makes Up Roughly 10.5% Of The Linux Kernel

Written by Michael Larabel in Linux Kernel on 11 October 2020 at 03:05 PM EDT. 46 Comments
LINUX KERNEL
Given the impending release of Linux 5.9, I was having some fun with cloc today looking at the current lines of code count for this near-final Linux 5.9 kernel state.

As of today in Linux 5.9 Git, the kernel is about 20.49 million lines of code plus another 3.58 million lines of code comments and another 3.72 million blank lines. Or all in, Linux 5.9 comes in at roughly 27.81 million lines distributed among some fifty-nine thousand source files.
   69964 text files.
   69494 unique files.                                          
   10737 files ignored.

github.com/AlDanial/cloc v 1.82  T=95.88 s (618.0 files/s, 290045.7 lines/s)
------------------------------------------------------------------------------
Language                    files          blank        comment           code
------------------------------------------------------------------------------
C                           29198        2900014        2367000       14781314
C/C++ Header                21123         588426        1022774        4640918
reStructuredText             2685         135238          59051         369738
Assembly                     1275          45960          99012         225085
JSON                          287              0              0         165799
YAML                         1089          18494           4966          83627
Bourne Shell                  657          16823          11350          66043
make                         2592           9808          10864          44192
SVG                            59            118           1365          37555
Perl                           60           6686           4767          34393
Python                        123           5345           4804          27720
yacc                            9            695            354           4755
PO File                         5            791            918           3077
lex                             9            349            304           2130
C++                            10            345            134           1993
Bourne Again Shell             52            338            297           1750
awk                            10            139            116           1051
Glade                           1             58              0            603
NAnt script                     2            143              0            549
Cucumber                        1             28             50            175
Windows Module Definition       2             15              0            109
m4                              1             15              1             95
CSS                             1             28             29             80
XSLT                            5             13             26             61
vim script                      1              3             12             27
Ruby                            1              4              0             25
INI                             1              1              0              6
sed                             1              2              5              5
------------------------------------------------------------------------------
SUM:                        59260        3729879        3588199       20492875
------------------------------------------------------------------------------

(Keep in mind the kernel source tree also has various tools, the build system, and plenty of documentation and the like that explains for some of the cloc data that may otherwise seem rather peculiar.)

For a while now the AMDGPU kernel graphics driver has been around 2+ million lines of code making it the largest in-tree kernel driver. With Linux 5.9, it comes in at 2.16 million lines of code plus another 247k lines of code comments and another 109k blank lines... Or up to 2.51 million lines of code is the AMD DRM driver code including AMDKFD, PowerPlay, DC, and all the kernel code ultimately making up the AMD Radeon support on that driver (but not the older Radeon DRM driver -- that older Radeon driver is at around 157k lines of code).

Though as reported previously, much of the AMDGPU driver code base is so large because of auto-generated header files for GPU registers, etc. In fact, 1.79 million lines as of Linux 5.9 for AMDGPU is simply header files that are predominantly auto-generated. It's 366k lines of the 2.71 million lines of code that is actual C code.
    1471 text files.
    1470 unique files.                                          
       5 files ignored.

github.com/AlDanial/cloc v 1.82  T=6.85 s (214.1 files/s, 367938.0 lines/s)
---------------------------------------------------------------------
Language           files          blank        comment           code
---------------------------------------------------------------------
C/C++ Header         927          39761         195391        1794207
C                    501          68528          50377         366823
Assembly               3            557            408           1909
make                  35            276            906            636
---------------------------------------------------------------------
SUM:                1466         109122         247082        2163575

For GPU driver size comparison, the Intel "i915" kernel driver supporting form old i915 graphics through Gen12 / Xe Graphics with Linux 5.9 is at 209k lines of code with another 39.2k lines of comments and 48k blank lines.
     529 text files.
     528 unique files.                                          
       6 files ignored.

github.com/AlDanial/cloc v 1.82  T=0.72 s (728.7 files/s, 413015.9 lines/s)
----------------------------------------------------------------------
Language            files          blank        comment           code
----------------------------------------------------------------------
C                     281          42116          31405         180728
C/C++ Header          238           5920           7719          27974
make                    2             23             29            260
Assembly                2             28             94            114
----------------------------------------------------------------------
SUM:                  523          48087          39247         209076
----------------------------------------------------------------------

Or in the case of the open-source NVIDIA "Nouveau" driver is just 149k lines of code, 25.6k lines of comments, and another 19.9k blank lines.

Those are the latest numbers for those wondering about the current size of the AMDGPU kernel driver in relation to the overall size of the mainline Linux 5.9 kernel. Obviously keep in mind these metrics are simply for the kernel side and not the user-space OpenGL/Vulkan and compute components.

In any case, there are lots of great Linux 5.9 kernel features to enjoy once released as stable in the coming hours.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week