Live data from Hacker News

Rust in the kernel is no longer experimental

lwn.net

401–410 of 853 posts

Re: Rust in the kernel is no longer experimental

#401
post #328

Earlier quoted context omitted.

> I am not sure what point did you try to make by giving something that is not even a production quality code? let's start by prefacing that 'production quality' C is 100% unsafe in Rust terms. > Sorry, I am not buying that argument. here's where we fundamentally disagree: you listed a couple dozen unsafe places in 1.5kLOC of code; let's be generous and say that's 10% - and you're trying to sell it as a bad thing, wh…

> let's start by prefacing that 'production quality' C is 100% unsafe in Rust terms. I don't know what one should even make from that statement. > here's where we fundamentally disagree: you listed a couple dozen unsafe places in 1.5kLOC of code; let's be generous and say that's 10% It's more than 10%, you didn't even bother to look at the code but still presented it, what in reality is a toy driver example, as somet…

> I don't know what one should even make from that statement.

it's just a fact. by definition of the Rust language unsafe Rust is approximately as safe as C (technically Rust is still safer than C in its unsafe blocks, but we can ignore that.)

> you didn't even bother to look at the code but still presented

of course I did, what I've seen were one-liner trait impls (the 'whole traits' from your own post) and sub-line expressions of unsafe access to bindings.

Re: Rust in the kernel is no longer experimental

#404

And yet, the Linux kernel's Rust code uses unstable features only available on a nightly compiler. Not optimal for ease of compilation and building old versions of the Kernel. (You need a specific version of the nightly compiler to build a specific version of the Kernel)

Don't the C parts of Linux heavily depend on GCC extensions too? Seems depending on specific compiler features isn't really a blocker.

Re: Rust in the kernel is no longer experimental

#405

That is so good to hear. I feel Rust support came a long way in the past two years and you can do a functional Rust kernel module now with almost no boilerplate. Removing the "experimental" tag is certainly a milestone to celebrate. I'm looking forward to distros shipping a default kernel with Rust support enabled. That, to me, will be the real point of no return, where Rust is so prevalent that there will be no goin…

[flagged]

Going off on the name makes your entire question and argument subjective and useless in a constructive discussion.

Re: Rust in the kernel is no longer experimental

#406

This is great because it means someday (possibly soon) Linux development will slowly grind to a halt and become unmaintainable, so we can start from scratch and write a new kernel.

Or you can take this as a sign that the linux kernel adapts modern programming languages so that more programmers can contribute :)

> the linux kernel adapts modern programming languages so that more programmers can contribute :)

I'm eagerly awaiting the day the Linux kernel is rewritten in Typescript so that more programmers can contribute :)

Re: Rust in the kernel is no longer experimental

#407

Earlier quoted context omitted.

I don't think unsafe Rust has gotten any easier to write, but I'd also be surprised if there was much unsafe except in the low-level stuff (hard to write Vec without unsafe), and to interface with C which is actually not hard to write. Mostly Rust has been used for drivers so far. Here's the first Rust driver I found: https://github.com/torvalds/linux/blob/2137cb863b80187103151... It has one trivial use of `unsafe` -…

Drivers are interesting from a safety perspective, because on systems without an IOMMU sending the wrong command to devices can potentially overwrite most of RAM. For example, if the safe wrappers let you write arbitrary data to a PCIe network card’s registers you could retarget a receive queue to the middle of a kernel memory page.

> if the safe wrappers let you write arbitrary data to a PCIe network card’s registers

Functions like that can and should be marked unsafe in rust. The unsafe keyword in rust is used both to say “I want this block to have access to unsafe rust’s power” and to mark a function as being only callable from an unsafe context. This sounds like a perfect use for the latter.

Re: Rust in the kernel is no longer experimental

#408

Earlier quoted context omitted.

The Unix/C people wrote their own kernel in the 1970s instead of invading an existing one.

If rust didn’t provide value to the Linux kernel, there’s no way it would have made out of the experimental phase. Rust isn’t an invading tribe. It’s just a tool.

> If rust didn’t provide value to the Linux kernel, there’s no way it would have made out of the experimental phase.

That’s “appeal to authority” fallacy.

Re: Rust in the kernel is no longer experimental

#409

Earlier quoted context omitted.

Complexity of Rust is just codifying existing complexity.

I've been working on Rust bindings for a C SDK recently, and the Rust wrapper code was far more complex than the C code it wrapped. I ended up ceding and getting reasonable wrappers by limiting how it can be used, instead of moddeling the C API's full capabilities. There are certainly sound, reasonable models of memory ownership that are difficult or impossible to express with Rust's ownership model. Sure, a differen…

Which SDK? I've only written Rust FFI to pretty basic C APIs. I'm curious to get a sense of the limitations on something more complex

Re: Rust in the kernel is no longer experimental

#410

Earlier quoted context omitted.

The Unix/C people wrote their own kernel in the 1970s instead of invading an existing one.

If rust didn’t provide value to the Linux kernel, there’s no way it would have made out of the experimental phase. Rust isn’t an invading tribe. It’s just a tool.

> Rust isn’t an invading tribe

People doing open-source work often feel very tribal about their code and block ideas that are good but threaten their position in the community. Essentially same thing as office politics except it's not about money, it's about personal pride.

Post reply on HN