Rust in the Linux kernel.

Data for every release from v6.1 to v7.4-rc2 (release candidate) · last updated

Rust support landed in Linux 6.1 at the end of 2022. Since then every release has added a bit more: abstractions in rust/, then real drivers for GPUs, network PHYs, Android Binder and more. This page counts what is actually in the tree for every release since v6.1: how many lines of Rust there are, where they live, how much of it is unsafe, and which C functions the Rust code calls. Rust is still a very small part of the kernel. The numbers below show how small, and how fast it is growing.

Newest tag: v7.4-rc2 (release candidate)

Tagged 2026-11-09. All counts are lines of code: non-blank, non-comment.

Rust code lines written for the kernel
64,110
plus 68,224 vendored = 132,334 in total
Rust share of the kernel
0.22%
0.46% with vendored crates. Against 28,843,329 lines of C and headers.
.rs files
568
211 of them vendored
Rust drivers in tree
10
Growth since v6.1
84×
765 → 64,110 first-party lines; 27.1× with vendored

Growth

Rust code lines per release, stacked by where they live in the tree. Vendored third-party crates are grey and hatched: they are copied in, not written for the kernel. The big jump in 6.19 is mostly the vendored syn, quote and proc-macro2 crates, added so the kernel's procedural macros can parse Rust properly.

Rust share of the kernel, first-party only

First-party Rust as a percentage of first-party Rust plus C and headers. Separate chart because the scale is nothing like the line counts above.

Table view: Rust code per release
TagDateCore abstractions (rust/)DriversSamplesOther (lib, mm, scripts, tools)Vendored third-party cratesTotalShareShare (first-party)
v6.12022-12-115950381324,1154,8800.021%0.003%
v6.22023-02-191,2090791324,1465,5660.023%0.006%
v6.32023-04-231,4640791323,8905,5650.023%0.007%
v6.42023-06-253,3870921324,1067,7170.032%0.015%
v6.52023-08-273,5570921324,3238,1040.033%0.016%
v6.62023-10-303,9410923434,3028,6780.035%0.018%
v6.72024-01-074,1870923434,2718,8930.036%0.019%
v6.82024-03-104,66795923504,2889,4920.038%0.021%
v6.92024-05-124,91595923524,3579,8110.039%0.022%
v6.102024-07-145,190959235305,7300.023%0.023%
v6.112024-09-156,0031439236906,6070.025%0.025%
v6.122024-11-177,4829979241008,9810.034%0.034%
v6.132025-01-199,108999103410010,6200.04%0.04%
v6.142025-03-2410,0791,004359426011,8680.045%0.045%
v6.152025-05-2512,1191,250436428014,2330.054%0.054%
v6.162025-07-2716,1171,909677434019,1370.071%0.071%
v6.172025-09-2817,8194,242761444023,2660.086%0.086%
v6.182025-11-3022,11312,5051,039523036,1800.134%0.134%
v6.192026-02-0824,71915,9901,20052447,02189,4540.327%0.156%
v7.02026-04-1225,41016,3971,32554547,02190,6980.329%0.159%
v7.12026-06-1427,41016,9881,36854947,02193,3360.336%0.167%
v7.22026-08-1628,99119,7261,42654963,885114,5770.407%0.181%
v7.32026-10-1831,87922,2371,54257763,885120,1200.421%0.197%
v7.4-rc22026-11-0935,57026,4451,55154468,224132,3340.457%0.222%

Where the Rust lives

Code lines in v7.4-rc2, per driver or subsystem, against the core abstractions in rust/ and the vendored crates.

Table view
ComponentPathCode lines
Core abstractionsrust/35,570
NVIDIA nova-core (GSP)drivers/gpu/nova-core/13,168
Android Binder IPC driverdrivers/android/binder/7,748
Tyr (Arm Mali GPU DRM driver)drivers/gpu/drm/tyr/3,585
Rust samplessamples/rust/1,551
DRM panic QR code generatordrivers/gpu/drm/drm_panic_helper_qr.rs787
rnull null block driverdrivers/block/rnull/313
T-HEAD TH1520 PWM driverdrivers/pwm/pwm_th1520.rs275
NVIDIA nova DRM driverdrivers/gpu/drm/nova/243
Device-tree cpufreq driver (Rust)drivers/cpufreq/rcpufreq_dt.rs163
ASIX AX88796B PHY driverdrivers/net/phy/ax88796b_rust.rs93
find_bit benchmark (Rust)lib/find_bit_benchmark_rust.rs79
Marvell QT2025 PHY driverdrivers/net/phy/qt2025.rs70
KASAN Rust testmm/kasan/kasan_test_rust.rs12
Samplessamples/rust/1,551
proc_macro2 (vendored)rust/proc-macro2/3,838
quote (vendored)rust/quote/1,460
syn (vendored)rust/syn/41,716
zerocopy_derive (vendored)rust/zerocopy-derive/3,374
zerocopy (vendored)rust/zerocopy/src/16,817

Anatomy

What the first-party Rust in v7.4-rc2 is made of, counted by parsing every file with syn (vendored crates left out). Code inside macro invocations such as module! {} is not counted.

Functions
4,503
418 free, 3,702 in impls, 383 in traits
Structs
910
Enums
116
Traits
192
Impl blocks
2,159
1,474 trait impls
macro_rules!
193
Proc macros
16

Functions per release

Unsafe and calls into C

Kernel Rust has to talk to C, and that takes unsafe. The core abstractions in rust/ exist to wrap it, so drivers need less of it. Kernel style asks for a // SAFETY: comment above every unsafe block explaining why it is sound.

unsafe blocks (first-party)
1,998
with // SAFETY: comment
87.1%
Call sites into C
591
521 distinct C functions via bindings::

unsafe blocks per 1,000 code lines

Area (v7.4-rc2)Code linesunsafe blocksper 1k lineswith SAFETY
Core abstractions (rust/)35,5701,80850.887%
Drivers26,445186785%
Samples1,55121.3100%

Share of unsafe blocks with a // SAFETY: comment

Most-called C functions

Top 15 in v7.4-rc2 by call sites through bindings::, out of 591 call sites in total. The list is flat on purpose: 591 call sites reach 521 different C functions, because the abstractions in rust/ wrap each C function once and everything else calls the safe wrapper.

Table view
#C functionCall sites
1bindings::get_device5
2bindings::_printk4
3bindings::put_device4
4bindings::rb_first4
5bindings::dma_alloc_attrs3
6bindings::dma_fence_put3
7bindings::drm_gpuva_link3
8bindings::fput3
9bindings::get_file3
10bindings::irqreturn_t3
11bindings::pwmchip_get_drvdata3
12bindings::rb_erase3
13bindings::rb_next3
14bindings::spin_unlock3
15bindings::__spin_lock_init2

The kernel's crates

The kernel does not use Cargo or crates.io. Its crates are built by Kbuild, the kernel's own build system, and the dependencies between them are declared by hand in rust/Makefile.

Arrows point from a crate to the crates it depends on directly. A link that already follows from a longer chain is not drawn, and neither is core from the Rust toolchain, which every crate uses. The table lists every dependency.

CrateKindDepends onCode linesFirst release
proc_macro2vendored3,838v6.19
quotevendoredproc_macro21,460v6.19
synvendoredproc_macro2 quote41,716v6.19
zerocopy_derivevendoredproc_macro2 quote syn3,374v7.2
macrosfirst-partyproc_macro2 quote syn1,483v6.1
pin_init_internalfirst-partyproc_macro2 quote syn3,073v6.15
coretoolchainsysrootv6.1
compiler_builtinsfirst-party74v6.1
zerocopyvendored16,817v7.2
pin_initfirst-partypin_init_internal macros968v6.15
build_errorfirst-party8v6.2
ffifirst-party25v6.13
bindingsfirst-partyffi pin_init78v6.1
uapifirst-partyffi pin_init29v6.4
kernelfirst-partyffi pin_init build_error macros bindings uapi zerocopy zerocopy_derive29,139v6.1

No longer built: alloc (v6.1 to v6.12)

What drivers import from kernel::

Files outside rust/ with at least one use kernel::<module>, in v7.4-rc2.

Table view
ModuleFiles
kernel::prelude121
kernel::io55
kernel::device51
kernel::sync41
kernel::sizes29
kernel::time22
kernel::dma21
kernel::num17
kernel::pci15
kernel::transmute15
kernel::new_mutex13
kernel::str13
kernel::uapi13
kernel::ptr12
kernel::seq_file11
kernel::bindings10
kernel::seq_print10
kernel::task10
kernel::of9
kernel::page9
kernel::types9
kernel::uaccess9
kernel::drm8
kernel::error8
kernel::bitfield7

Driver timeline

Rust drivers and subsystems outside rust/, by the release they first appeared in.

  1. v6.1
    Rust samples
    samples/rust/
    1,551 code lines in v7.4-rc2
  2. v6.8
    ASIX AX88796B PHY driver
    drivers/net/phy/ax88796b_rust.rs
    93 code lines in v7.4-rc2
  3. v6.11
    rnull null block driver
    drivers/block/rnull/
    313 code lines in v7.4-rc2
  4. v6.12
    DRM panic QR code generator
    drivers/gpu/drm/drm_panic_helper_qr.rs
    787 code lines in v7.4-rc2
  5. v6.12
    KASAN Rust test
    mm/kasan/kasan_test_rust.rs
    12 code lines in v7.4-rc2
  6. v6.12
    Marvell QT2025 PHY driver
    drivers/net/phy/qt2025.rs
    70 code lines in v7.4-rc2
  7. v6.15
    NVIDIA nova-core (GSP)
    drivers/gpu/nova-core/
    13,168 code lines in v7.4-rc2
  8. v6.16
    NVIDIA nova DRM driver
    drivers/gpu/drm/nova/
    243 code lines in v7.4-rc2
  9. v6.16
    Device-tree cpufreq driver (Rust)
    drivers/cpufreq/rcpufreq_dt.rs
    163 code lines in v7.4-rc2
  10. v6.18
    Android Binder IPC driver
    drivers/android/binder/
    7,748 code lines in v7.4-rc2
  11. v6.18
    find_bit benchmark (Rust)
    lib/find_bit_benchmark_rust.rs
    79 code lines in v7.4-rc2
  12. v6.18
    Tyr (Arm Mali GPU DRM driver)
    drivers/gpu/drm/tyr/
    3,585 code lines in v7.4-rc2
  13. v6.19
    T-HEAD TH1520 PWM driver
    drivers/pwm/pwm_th1520.rs
    275 code lines in v7.4-rc2

Methodology

  • Every tagged release from v6.1 on is downloaded from the mainline tree, plus the newest release candidate when it is newer than the newest release.
  • Lines are counted by the rules of tokei, within 0.1% of tokei itself: code lines exclude blanks and comments, and doc comments count as comments. The kernel's share counts Rust against *.c plus *.h files.
  • Items, unsafe and calls into C are counted by parsing every .rs file with syn. The bodies of macro invocations and macro_rules! definitions are not parsed, so code generated by macros is not counted.
  • Vendored third-party crates (proc_macro2, quote, syn, zerocopy, zerocopy_derive) are shown separately and left out of the first-party numbers.
  • A call into C is a call whose path goes through bindings::. Calls made through the safe wrappers in the kernel crate count once, at the wrapper.

Cross-checks

TagSourceTheir RustOursTheir C (.c only)Ours
v6.17LWN, 'Development statistics for 6.19' comments23,16323,26618,951,31618,924,721
v6.18LWN, 'Development statistics for 6.19' comments36,07736,18019,041,64519,015,046
v6.19LWN, 'Development statistics for 6.19' comments89,28689,45419,222,91019,196,331

The analyzer is open source and reproducible (kernel-rust-stats 0.1.0). You can download the data as JSON.

Last updated 2026-11-11T15:52:32Z.