Rust For Linux Kernel v9 Patches Trim Things Down Greatly For Easier Upstreaming .

Rust Coding



Earlier this week saw the Rust for Linux v8 patches posted that introduced a number of new abstractions and expanding the Rust programming language integration to more areas of the kernel. Those patches amounted to 43.6k lines of new code while "Rust for Linux v9" was posted today and comes in at just 12.5k lines of new code.

Rust for Linux v9 is significantly smaller than the prior patches due to removing a lot of extra features and integration. The hope is now to take a more initial minimal route with the Rust for Linux integration until that initial mainlining and then from there can build things up with the enhanced integration and allowing more involved review/feedback of the various abstractions and subsystem-specific patches.

Rust for Linux lead developer Miguel Ojeda commented with the v9 patches:

"This is a trimmed down v8. It has enough support to compile a minimal Rust kernel module, with the aim to get the "core" support in first and then start upstreaming the rest piece by piece.

The kernel module is able to create a `Vec` (a contiguous, growable array type), push some numbers and print them on unload to the kernel log with the `pr_info!` macro.

The patch series could be made even more minimal by removing some of that too, but this seemed like a good balance.

After the diet regime, 3% of the `kernel` crate remains (down to 500 lines), 60% of `alloc`, and the "adapt `alloc`" commit is 100 lines. Overall, we went from 40 to 13 klines.

Most of the code has been around in linux-next for some months now, but to trim down things I had to do minor changes. In any case, please let me know if this selection is in line with what you expected."

With the v9 patches being significantly less and sticking to the basics, it should be much easier to get clearance on mainlining it in a timely manner. Linus Torvalds has been wanting to merge it soon, so we'll see if this simplified work is now good enough that Linus Torvalds could go ahead and merge it over the next week for the Linux 6.0 merge window.

Rust could soon complement C as a supported language for Linux kernel driver development.