September 25th, 2024

Committing to Rust in the Kernel

The integration of Rust into the Linux kernel is ongoing, facing mixed developer reactions. Focused on device drivers, the community is optimistic about future contributions despite slow progress and challenges.

Read original articleLink Icon
Committing to Rust in the Kernel

The integration of Rust into the Linux kernel has been progressing for several years, with ongoing discussions about its status and future at the 2024 Maintainers Summit. Miguel Ojeda led a session addressing the need for flexibility from subsystem maintainers to accommodate Rust code, which has been met with mixed reactions from developers. While some express frustration over the slow pace of merging new functionalities, others see potential in Rust's ability to enhance kernel safety and performance. Key figures like Greg Kroah-Hartman and Linus Torvalds acknowledged that while the project is still experimental, it is viable and should continue to advance. The focus has been primarily on device drivers, which require extensive support code, contributing to the slower integration process. Developers are encouraged to manage expectations, as merging Rust code will take time, and the community is working to provide necessary documentation and support. The first successful driver merge is anticipated to be a significant milestone, potentially accelerating further Rust integration. Overall, while there are challenges, the kernel community is optimistic about Rust's future contributions.

- Rust integration into the Linux kernel is ongoing but slow.

- Developers express mixed feelings about the project's experimental status.

- The focus is currently on device drivers, which complicates integration.

- Documentation and support for Rust in the kernel are being developed.

- The first successful driver merge is expected to boost momentum for Rust adoption.

Link Icon 18 comments
By @p1necone - 4 months
"Torvalds said that it is not necessary to understand Rust to let it into a subsystem; after all, he said, nobody understands the memory-management subsystem, but everybody is able to work with it."

Chuckled a bit at this line, anyone have context on how true this is?

By @saagarjha - 4 months
Aside: LWN is basically what ChatGPT summarization as advertised itself to be, except it's actually good and coherent and useful. I can trust Jonathan to summarize the conversation in a way that is mostly sane and reasonable in a way that I can never hand off the job to generative AI. It's an important area where humans seem to excel over computers.

Also, just to have some content that is actually on-topic: is anyone actually shipping upstream Linux Rust code yet? I understand that some stuff is slowly merging in but I'm not sure if it's actually being exercised yet.

By @jsheard - 4 months
On a semi-tangent, does anyone happen to know how Microsofts push to use Rust in the Windows kernel is coming along? They rewrote some components in Rust and rolled them out to production about a year ago but it has seemed pretty quiet on that front since then, unless I missed something.
By @newpavlov - 4 months
>Changing C interfaces will often have implications for the Rust code and may break it; somebody will the have to fix the problems. Torvalds said that, for now, breaking the Rust code is permissible, but that will change at some point in the future.

I think this is the main technical change needed from the Linux kernel. It needs a layer of quasi-stable well documented subsystem APIs, which ideally would be "inherently safe" or at least have clear safe usage contracts. And it's fine for these interfaces to have relaxed stability guarantees in the early (pre-1.0, if you will) experimental stages. Changing them would involve more work and synchronization (C maintainers would not be able to quickly "refactor" these parts), but it's a familiar problem for many large projects.

It's the only reasonable point from the infamous tantrum by Ted Ts'o during the Rust for filesystems talk, everything else, to put it mildly, was a really disappointing behavior from a Linux subsystem maintainer.

By @brotchie - 4 months
Thought that ThePrimeTime in his video https://youtu.be/62oTu9hjxL4?si=E98WZ0zJSNUC8TEH&t=287 hit the nail on the head re: Rust versus C.

Max level C programmers, have designed their programming style around control down to the absolute bit. C derives control from absolute control over behavior.

Max level Rust programmers have complete mastery of types. Rust derives control from types.

Seems somewhat philosophically incompatible.

By @ristos - 4 months
Can anyone explain to me why these two issues aren't considered deal breakers for introducing Rust into the kernel?

1. It doesn't map almost 1:1 to assembly the way C does, so it's not inherently clear if the code will necessarily do what it says it does. That seems questionable for something as important as a kernel and driver.

2. Only one real Rust compiler, that's a recursive compiler, which reminds me of the Trusting Trust problem: https://dl.acm.org/doi/abs/10.1145/358198.358210

By @aero-glide2 - 4 months
Even though I don't use Linux in my projects, Rust on Linux is extremely important to convince others to use Rust. I hope it succeeds.
By @deivid - 4 months
Not exactly rust-in-kernel, but I've been using Aya[0] to write ebpf programs in Rust and it is quite nice. The verifier is still a bit trigger-happy with some constructs, but it is manageable.

[0]: https://aya-rs.dev/

By @duped - 4 months
Totally unrelated comment to my previous one

I think it's folly to encode the semantics of APIs in the Rust type system and memory model and that's the impedance mismatch that has people riled up. unsafe code isn't incorrect code, and trying to add abstraction where there wasn't one before is encoding principles where they didn't previously exist and should be an obvious problem.

I've written a lot of systems-type Rust using unsafe and I think the design pattern of -sys bindings and then a higher level safe wrapper is mostly incorrect because callers should always use the -sys bindings directly. It's more workable and doesn't suffer from changes that the detractors complain about.

By @duped - 4 months
What is the value in relying on distro authors to publish rust compiler versions, when the bespoke release channel for rustc is kept much more up to date?
By @strken - 4 months
Does Rust support the same range of architectures as C? Or is there some way to compile Rust to C to support weird obscure systems?

Forgive me if this is something commonly known by the people involved. It just strikes me as the most obvious objection to Rust in the kernel and I haven't seen any explanation of what's going to happen.

By @debo_ - 4 months
As a side note, does anyone know what the backup plan is if Linus is suddenly no longer able to lead in his current capacity? I think it's likely there is one, but am not sure what it is.
By @pjmlp - 4 months
Regardless of what upstream decides, downstream on ChromeOS and Android land, it is already being used.
By @Waterluvian - 4 months
I’ve read many times that a goal is to see if the use of Rust can work out in the kernel.

What does this experiment for? What exactly is the evaluation? What are some example findings, both pro and con?

By @IshKebab - 4 months
> he also is unable to work with Rust until a suitable compiler is available in RHEL

What an arse. Best to ignore these people.

By @cozzyd - 4 months
Why can't all symbols exported to modules maintain a C ABI, obviating (if I understand correctly) the genksyms problem?
By @stonethrowaway - 4 months
With the Rust team falling apart, who is actually long term going to maintain it? I want to use it but I just see drama.