Rust in the Linux kernel.
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.
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
| Tag | Date | Core abstractions (rust/) | Drivers | Samples | Other (lib, mm, scripts, tools) | Vendored third-party crates | Total | Share | Share (first-party) |
|---|---|---|---|---|---|---|---|---|---|
v6.1 | 2022-12-11 | 595 | 0 | 38 | 132 | 4,115 | 4,880 | 0.021% | 0.003% |
v6.2 | 2023-02-19 | 1,209 | 0 | 79 | 132 | 4,146 | 5,566 | 0.023% | 0.006% |
v6.3 | 2023-04-23 | 1,464 | 0 | 79 | 132 | 3,890 | 5,565 | 0.023% | 0.007% |
v6.4 | 2023-06-25 | 3,387 | 0 | 92 | 132 | 4,106 | 7,717 | 0.032% | 0.015% |
v6.5 | 2023-08-27 | 3,557 | 0 | 92 | 132 | 4,323 | 8,104 | 0.033% | 0.016% |
v6.6 | 2023-10-30 | 3,941 | 0 | 92 | 343 | 4,302 | 8,678 | 0.035% | 0.018% |
v6.7 | 2024-01-07 | 4,187 | 0 | 92 | 343 | 4,271 | 8,893 | 0.036% | 0.019% |
v6.8 | 2024-03-10 | 4,667 | 95 | 92 | 350 | 4,288 | 9,492 | 0.038% | 0.021% |
v6.9 | 2024-05-12 | 4,915 | 95 | 92 | 352 | 4,357 | 9,811 | 0.039% | 0.022% |
v6.10 | 2024-07-14 | 5,190 | 95 | 92 | 353 | 0 | 5,730 | 0.023% | 0.023% |
v6.11 | 2024-09-15 | 6,003 | 143 | 92 | 369 | 0 | 6,607 | 0.025% | 0.025% |
v6.12 | 2024-11-17 | 7,482 | 997 | 92 | 410 | 0 | 8,981 | 0.034% | 0.034% |
v6.13 | 2025-01-19 | 9,108 | 999 | 103 | 410 | 0 | 10,620 | 0.04% | 0.04% |
v6.14 | 2025-03-24 | 10,079 | 1,004 | 359 | 426 | 0 | 11,868 | 0.045% | 0.045% |
v6.15 | 2025-05-25 | 12,119 | 1,250 | 436 | 428 | 0 | 14,233 | 0.054% | 0.054% |
v6.16 | 2025-07-27 | 16,117 | 1,909 | 677 | 434 | 0 | 19,137 | 0.071% | 0.071% |
v6.17 | 2025-09-28 | 17,819 | 4,242 | 761 | 444 | 0 | 23,266 | 0.086% | 0.086% |
v6.18 | 2025-11-30 | 22,113 | 12,505 | 1,039 | 523 | 0 | 36,180 | 0.134% | 0.134% |
v6.19 | 2026-02-08 | 24,719 | 15,990 | 1,200 | 524 | 47,021 | 89,454 | 0.327% | 0.156% |
v7.0 | 2026-04-12 | 25,410 | 16,397 | 1,325 | 545 | 47,021 | 90,698 | 0.329% | 0.159% |
v7.1 | 2026-06-14 | 27,410 | 16,988 | 1,368 | 549 | 47,021 | 93,336 | 0.336% | 0.167% |
v7.2 | 2026-08-16 | 28,991 | 19,726 | 1,426 | 549 | 63,885 | 114,577 | 0.407% | 0.181% |
v7.3 | 2026-10-18 | 31,879 | 22,237 | 1,542 | 577 | 63,885 | 120,120 | 0.421% | 0.197% |
v7.4-rc2 | 2026-11-09 | 35,570 | 26,445 | 1,551 | 544 | 68,224 | 132,334 | 0.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
| Component | Path | Code lines |
|---|---|---|
| Core abstractions | rust/ | 35,570 |
| NVIDIA nova-core (GSP) | drivers/gpu/nova-core/ | 13,168 |
| Android Binder IPC driver | drivers/android/binder/ | 7,748 |
| Tyr (Arm Mali GPU DRM driver) | drivers/gpu/drm/tyr/ | 3,585 |
| Rust samples | samples/rust/ | 1,551 |
| DRM panic QR code generator | drivers/gpu/drm/drm_panic_helper_qr.rs | 787 |
| rnull null block driver | drivers/block/rnull/ | 313 |
| T-HEAD TH1520 PWM driver | drivers/pwm/pwm_th1520.rs | 275 |
| NVIDIA nova DRM driver | drivers/gpu/drm/nova/ | 243 |
| Device-tree cpufreq driver (Rust) | drivers/cpufreq/rcpufreq_dt.rs | 163 |
| ASIX AX88796B PHY driver | drivers/net/phy/ax88796b_rust.rs | 93 |
| find_bit benchmark (Rust) | lib/find_bit_benchmark_rust.rs | 79 |
| Marvell QT2025 PHY driver | drivers/net/phy/qt2025.rs | 70 |
| KASAN Rust test | mm/kasan/kasan_test_rust.rs | 12 |
| Samples | samples/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 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.
bindings::unsafe blocks per 1,000 code lines
| Area (v7.4-rc2) | Code lines | unsafe blocks | per 1k lines | with SAFETY |
|---|---|---|---|---|
| Core abstractions (rust/) | 35,570 | 1,808 | 50.8 | 87% |
| Drivers | 26,445 | 186 | 7 | 85% |
| Samples | 1,551 | 2 | 1.3 | 100% |
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 function | Call sites |
|---|---|---|
| 1 | bindings::get_device | 5 |
| 2 | bindings::_printk | 4 |
| 3 | bindings::put_device | 4 |
| 4 | bindings::rb_first | 4 |
| 5 | bindings::dma_alloc_attrs | 3 |
| 6 | bindings::dma_fence_put | 3 |
| 7 | bindings::drm_gpuva_link | 3 |
| 8 | bindings::fput | 3 |
| 9 | bindings::get_file | 3 |
| 10 | bindings::irqreturn_t | 3 |
| 11 | bindings::pwmchip_get_drvdata | 3 |
| 12 | bindings::rb_erase | 3 |
| 13 | bindings::rb_next | 3 |
| 14 | bindings::spin_unlock | 3 |
| 15 | bindings::__spin_lock_init | 2 |
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.
| Crate | Kind | Depends on | Code lines | First release |
|---|---|---|---|---|
proc_macro2 | vendored | 3,838 | v6.19 | |
quote | vendored | proc_macro2 | 1,460 | v6.19 |
syn | vendored | proc_macro2 quote | 41,716 | v6.19 |
zerocopy_derive | vendored | proc_macro2 quote syn | 3,374 | v7.2 |
macros | first-party | proc_macro2 quote syn | 1,483 | v6.1 |
pin_init_internal | first-party | proc_macro2 quote syn | 3,073 | v6.15 |
core | toolchain | sysroot | v6.1 | |
compiler_builtins | first-party | 74 | v6.1 | |
zerocopy | vendored | 16,817 | v7.2 | |
pin_init | first-party | pin_init_internal macros | 968 | v6.15 |
build_error | first-party | 8 | v6.2 | |
ffi | first-party | 25 | v6.13 | |
bindings | first-party | ffi pin_init | 78 | v6.1 |
uapi | first-party | ffi pin_init | 29 | v6.4 |
kernel | first-party | ffi pin_init build_error macros bindings uapi zerocopy zerocopy_derive | 29,139 | v6.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
| Module | Files |
|---|---|
kernel::prelude | 121 |
kernel::io | 55 |
kernel::device | 51 |
kernel::sync | 41 |
kernel::sizes | 29 |
kernel::time | 22 |
kernel::dma | 21 |
kernel::num | 17 |
kernel::pci | 15 |
kernel::transmute | 15 |
kernel::new_mutex | 13 |
kernel::str | 13 |
kernel::uapi | 13 |
kernel::ptr | 12 |
kernel::seq_file | 11 |
kernel::bindings | 10 |
kernel::seq_print | 10 |
kernel::task | 10 |
kernel::of | 9 |
kernel::page | 9 |
kernel::types | 9 |
kernel::uaccess | 9 |
kernel::drm | 8 |
kernel::error | 8 |
kernel::bitfield | 7 |
Driver timeline
Rust drivers and subsystems outside rust/, by the release they first appeared in.
v6.1Rust samplessamples/rust/v6.8ASIX AX88796B PHY driverdrivers/net/phy/ax88796b_rust.rsv6.11rnull null block driverdrivers/block/rnull/v6.12DRM panic QR code generatordrivers/gpu/drm/drm_panic_helper_qr.rsv6.12KASAN Rust testmm/kasan/kasan_test_rust.rsv6.12Marvell QT2025 PHY driverdrivers/net/phy/qt2025.rsv6.15NVIDIA nova-core (GSP)drivers/gpu/nova-core/v6.16NVIDIA nova DRM driverdrivers/gpu/drm/nova/v6.16Device-tree cpufreq driver (Rust)drivers/cpufreq/rcpufreq_dt.rsv6.18Android Binder IPC driverdrivers/android/binder/v6.18find_bit benchmark (Rust)lib/find_bit_benchmark_rust.rsv6.18Tyr (Arm Mali GPU DRM driver)drivers/gpu/drm/tyr/v6.19T-HEAD TH1520 PWM driverdrivers/pwm/pwm_th1520.rs
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
*.cplus*.hfiles. - Items,
unsafeand calls into C are counted by parsing every.rsfile with syn. The bodies of macro invocations andmacro_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 thekernelcrate count once, at the wrapper.
Cross-checks
| Tag | Source | Their Rust | Ours | Their C (.c only) | Ours |
|---|---|---|---|---|---|
v6.17 | LWN, 'Development statistics for 6.19' comments | 23,163 | 23,266 | 18,951,316 | 18,924,721 |
v6.18 | LWN, 'Development statistics for 6.19' comments | 36,077 | 36,180 | 19,041,645 | 19,015,046 |
v6.19 | LWN, 'Development statistics for 6.19' comments | 89,286 | 89,454 | 19,222,910 | 19,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.