Rust Developers Move Ahead With Preparing To Upstream More Code Into The Linux Kernel

Written by Michael Larabel in Linux Kernel on 11 November 2022 at 05:36 AM EST. 57 Comments
LINUX KERNEL
With the upcoming Linux 6.1 kernel release there is the initial Rust infrastructure merged for enabling the use of the Rust programming language for future kernel drivers and other kernel code. But that state in Linux 6.1 is the very basics and not yet practical while now a secondary sent of "Rust for Linux" patches have been sent out for enabling more kernel development to happen with Rust.

Miguel Ojeda who has been leading the Rust for Linux effort sent out a set of 28 patches on Thursday that provide more Rust core additions to the kernel. Ojeda explained in the patch series this latest big patch series:
This patch series is the first batch of changes to upstream the rest of the Rust support.

In this instance, all the facilities introduced are part of the "Rust core". They do not interact with the C side in new major ways (no new C types used; only `strlen`, `memchr`, additional error codes and some more `printk` format strings).

After this series, `str.rs` and `print.rs` are in sync with downstream and all remaining proc macros have been added. `error.rs` is fairly complete too, though a few more `pub(crate)` features will come later (to avoid leaving dead code in-between series).

Note that a few temporary `#[allow(dead_code)]` attributes are used in order to have a bit more freedom organizing the patches while keeping all of them buildable without warnings/errors, but at the end of the series there is none remaining (of the temporary ones).

Virtually all the code has been in linux-next for months and was part of the Rust patch series before the trimming down (i.e. up to v8).

Each patch has been built-tested on a Rust-enabled `defconfig` with `CLIPPY=1` on the `all`, `rustfmtcheck`, `rustdoc` and `rusttest` targets.

Given that this code has been in linux-next for a while and already saw some review as part of the original Rust for Linux patch series, it's quite possible we could see this work ready in time for the Linux 6.2 merge window next month. We'll see. In any case the Rust for Linux train continues rolling on.


Once all this Rust infrastructure is in place, we'll see how long it takes before more prominent, real-world drivers begin transitioning over to Rust code either for new hardware support or rewriting existing C driver code in Rust. One of the first major users of Rust in the Linux kernel is expected to be the DRM driver for the Apple M1/M2 graphics.

Separately, yesterday the US National Security Agency published guidance on protecting against memory safety issues. The NSA report suggests using the Rust programming language or other memory-safe languages like Swift, Java, Go, Ruby, and C#.
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