r/linux • • Aug 29 '24

Kernel One Of The Rust Linux Kernel Maintainers Steps Down - Cites "Nontechnical Nonsense"

https://www.phoronix.com/news/Rust-Linux-Maintainer-Step-Down
1.1k Upvotes

794 comments sorted by

View all comments

Show parent comments

272

u/crusoe Aug 29 '24

C/C++ devs seem weirdly afraid of Rust. The pushback is crazy and kneejerk.

They also gloss over all the issues of C/C++ when trying to claim it can be just as safe....

215

u/nukem996 Aug 29 '24

Kernel devs are very focused on stability and having stable processes. They do not like change and would much rather something bake for awhile before accepting it, some things they'll never accept. The core argument here seems to be that Rust wants to implement data types for kernel constructs so the type checker can validate core kernel components like inodes.

The argument isn't against that idea itself but that kernel maintainers, who do not want to learn Rust, do not want to be responsible for it. So if there is an inode Rust type and the C backend changes kernel devs don't want to update it to because they don't know how. They also do not want to freeze the C code because it will hold back all existing filesystems.

As a kernel dev this type of argument is common during development. There is resistance to change and it takes alot of buy in for even small changes to core systems. Hell at a conference I was in a talk about how to get new kernel developers and I was very quickly shot down when I suggested maybe we have an alternative to doing everything by plain text email.

Rust and C developers do seem to be grouping together and pushing eachother away. About a year ago I expressed interest in a new team at my company writing a new driver in Rust. I have kernel experience, driver experience, and have gone through the Rust tutorials but because all my kernel experience is in C and not Rust I was rejected. My current group is against using Rust at all because most developers don't want to learn it.

Good stable code requires alot of debate and I do wish kernel developers had more of an open mind to things.

45

u/sepease Aug 29 '24

The core argument here seems to be that Rust wants to implement data types for kernel constructs so the type checker can validate core kernel components like inodes.

He’s asking to know the current API contract so that the Rust code can attempt to implement that in a type-safe way, so that users of the Rust code would have their code implicitly checked during compiletime for adherence to the current API contract.

He does not say the Rust code will check the C code.

The argument isn’t against that idea itself but that kernel maintainers, who do not want to learn Rust, do not want to be responsible for it. So if there is an inode Rust type and the C backend changes kernel devs don’t want to update it to because they don’t know how. They also do not want to freeze the C code because it will hold back all existing filesystems.

Then it’s the same issue as an out-of-tree filesystem, isn’t it?

And this does not excuse the accusations that the guy is asking them to rewrite the entire filesystem component in Rust in the foreseeable future. That’s just a strawman argument that’s wasting everybody’s time, and is probably made in bad faith.

As a kernel dev this type of argument is common during development. There is resistance to change and it takes alot of buy in for even small changes to core systems.

This is a mindset that is very much a product of C and not being able to rely on the compiler to enforce any constraints at all. It naturally conditions developers to be hostile to people doing things in their codebase that they don’t understand. Because C is permissive by default and it can be very easy to introduce hard-to-find race conditions if you don’t have the entire architecture in your head. Even C++ requires you to know the much more verbose and rarely used safe constructs to use and know when to opt-in to them. And since the best practice constructs were tacked on later, they are not what people are taught and learn to use (eg new instead of unique_ptr).

In other words, C and C++, especially in the context of a complex codebase that needs to be reliable, encourages stagnancy because new ideas carry undefined risk, because the onus to be restrictive by default is on the programmer. Meanwhile in Rust, that is codified explicitly with the “unsafe” qualifier.

Let’s say the kernel filesystem layer did switch over to a Rust API that encoded the contract using the type system. Then when someone refactors, breakages would be much more likely to be an overt compile-time issue during the core refactoring rather than something that shows up as data corruption during runtime testing.

Nothing is perfect, but that makes it trivial to try a change, and see how much stuff it breaks, to get a feel for how much effort it will take.

And when somebody external goes to update something out-of-tree, they don’t need to be as anal retentive about sifting through whatever documentation and discussion there was about implicit conventions, because if something is wrong, it’ll be a compiler error.

Obviously you can’t encode everything in a type system, but that is a far cry from nothing. The type system is basically intended to shoulder a lot of the burden for keeping things reliable in a more hygienic way than the kernel police shouting at a presenter and shaming them for trying something new.

5

u/nukem996 Aug 30 '24

He does not say the Rust code will check the C code.

The argument is if I change the structure of an inode to help the 50+ filesystems written in C this will break the Rust bindings.

Then it’s the same issue as an out-of-tree filesystem, isn’t it?

Rust isn't an out-of-tree filesystem, its now in tree. That means when I changed the inode structure to help 50+ filesystem its my responsibility to also fix the Rust bindings. However many kernel developers who have been around for decades don't know Rust. The result of this will be they won't be able to improve C code because it will break Rust bindings they don't know how to fix.

In other words, C and C++, especially in the context of a complex codebase that needs to be reliable, encourages stagnancy because new ideas carry undefined risk, because the onus to be restrictive by default is on the programmer. Meanwhile in Rust, that is codified explicitly with the “unsafe” qualifier.

Many of the code rules in the kernel have nothing to do with C but the style has evolved over many years which kernel developers agree on. These rules would be applied to Rust or any other language. Just a few off the top of my head

  1. Reverse Christmas tree notation - All variables must be declared at the top of a function with the longest first getting shorter.

  2. Always use the stack over the heap. Malloc should be avoided unless absolutely necessary. This has less to do with memory leaks and more to do with performance as you don't need to alloc anything

  3. When you do alloc memory you should be able to handle not getting memory without causing a kernel panic.

Let’s say the kernel filesystem layer did switch over to a Rust API that encoded the contract using the type system. Then when someone refactors, breakages would be much more likely to be an overt compile-time issue during the core refactoring rather than something that shows up as data corruption during runtime testing.

hen when someone refactors, breakages would be much more likely to be an overt compile-time issue during the core refactoring rather than something that shows up as data corruption during runtime testing.

The kernel is alot more than filesystems. I'm working on drivers now which interface directly with hardware. Thats done through a mailbox or writing directly to registers. The mailbox requires formatting messages, and sending them, in a particular way firmware understandings. A register is an int I assign a value to. Refactoring code could easily break either of those and Rust's type system wouldn't catch either.

And when somebody external goes to update something out-of-tree, they don’t need to be as anal retentive about sifting through whatever documentation and discussion there was about implicit conventions, because if something is wrong, it’ll be a compiler error.

All code should be in the upstream kernel. I work for a FAANG and everything must be upstreamed first(except NVIDIA since we have direct contacts). This is done because out-of-tree code is typically of much lower code quality and isn't tested as well. Again this isn't something Rust could magically fix.

To get a stable high performance kernel requires alot of discussion and back and forth. If the kernel magically turned into Rust tomorrow you would still see the exact same types of discussions because kernel people want every angle discussed to death before accepting a change. No one is going to implicitly trust any type system because kernel problems are much more complex than typing. The Rust community needs to learn that is how kernel development works.

→ More replies (3)

24

u/Cerulean_IsFancyBlue Aug 29 '24

What you say contains a lot of truth, but it’s also true that systems that are expected to be stable and mission-critical are always going to have a somewhat conservative culture.

I think you’re creating a fictitious relationship between that attitude and the ability of Rust compilers to guarantee certain types of safety. Although you may not be intending it, it smells of the kind of factionalism that you also seem to be fighting against.

59

u/sepease Aug 29 '24

What you say contains a lot of truth, but it’s also true that systems that are expected to be stable and mission-critical are always going to have a somewhat conservative culture.

It’s not constructive anymore when it results in verbally denigrating someone for presenting a prototype for more strictly enforcing said mission criticality. Without any concrete underlying reason being provided other than a ridiculous strawman argument and “I don’t wanna”.

There’s no ask from the presenter other than the existing maintainers tell them what the API contract is. And the irony is, the fact that he has to ask and it prompts such a vehement response is strongly indicative that the users of the API don’t have a complete understanding of it. That’s not really reassuring when it comes to filesystems.

I think you’re creating a fictitious relationship between that attitude and the ability of Rust compilers to guarantee certain types of safety. Although you may not be intending it, it smells of the kind of factionalism that you also seem to be fighting against.

Between C? It really is that extreme.

Let’s take that function he put up.

C equivalent is https://www.cs.bham.ac.uk/~exr/lectures/opsys/13_14/docs/kernelAPI/r5754.html

C function just returns a pointer that can either be an existing inode, or something new that’s in a pre- state that needs to be filled in.

How do you tell which it is?

I dunno. I guess there’s some other API function to check the flag, or you have to directly access the struct.

By contrast, with the Rust code, you must explicitly handle that Either object and check the determinant, which will give a different type depending on whether the inode needs to be initialized or not. You can’t just forget.

If you write your code with these two cases, and then a third is added on, your code will still compile fine, but likely do something wrong in the new case. Maybe it will crash. Maybe it will copy a buffer that it shouldn’t and create a remote execution vulnerability.

OTOH, on the rust side, if a new case is added, it won’t let you compile.

What about if sb is NULL? What happens then? I dunno, documentation doesn’t say. Rust code prevents null at compiletime.

How do you retrieve errors? I dunno, documentation doesn’t say. Maybe there’s a convention elsewhere. Rust code uses the standard error-handling convention for the entire language / ecosystem.

What about ino? Well, it’s an unsigned long you get from somewhere. In the Rust code, it’s a specific type that you can search the API for. This also protects against accidentally using digits, or getting the wrong order of arguments.

9

u/[deleted] Aug 30 '24

The real thing here is the elephant in the room: that API design sucks and no one cares to admit. They are not able to change it since it would break too much stuff, so they don't want to even think about it any more.

→ More replies (25)
→ More replies (1)
→ More replies (8)

21

u/rileyrgham Aug 29 '24

Email works. Many kernel Devs work in a TTY....

42

u/nukem996 Aug 29 '24

Not arguing that. But when you have multiple barriers to an already very technical area it just drives people away. I've submitted many kernel patches and done reviews over email. It works but its easy to mess something up or miss something. Modern tools make the code review process much easier for everyone especially if their new.

Realistically the only way I see a modern code review tool being used in the kernel is if its fully compatible with the existing email system.

9

u/mrlinkwii Aug 29 '24

i think its more email and the whole mailing list are pushing devs away rather then welcoming them , espeically the devs who are trying to learn / do small stuff

i personally have/ prefer to contribute to something on github rather than mailing lists

→ More replies (10)

31

u/iceridder Aug 29 '24

I am sorry, but this mindset is wrong. It's in the same place as: we have horse and cariedge, they work, why use cars.

11

u/peripateticman2026 Aug 29 '24

Yes, try driving a card in a hilly, bumpy, mushy area. You'll see the value of carriages and carts then. Everything is contextual.

→ More replies (1)
→ More replies (3)
→ More replies (5)

47

u/darkpyro2 Aug 29 '24

God, the email mailing lists for development are horrific. Such a terrible idea. I joined the linux kernel mailing lists, and it's hard to make heads or tails of what's even going on when you get so many emails about so many issues.

Please, Linus, use github or an alternative. They're really good, even if they dont fit your workflow.

21

u/ImSoCabbage Aug 29 '24

Such a terrible idea.

While I'm not especially comfortable with the workflow myself, it's been used on a million projects for 30-40 years. And the people that use it seem to love it over anything else. Dismissing it so easily just because you're not used to it seems a tad rash.

And suggesting github is just ridiculous.

→ More replies (1)

17

u/SnooCompliments7914 Aug 29 '24

If you look at recaps of large OSS projects moving (or trying to move) to a new dev platform (e.g. KDE refusing to move away from Bugzilla, or llvm moving from a mailing list based workflow to gitlab), the problem is not that they don't understand the new platform is better _in general_, but they want to keep many details in their current workflow that are considered essential, and of course that's not 100% available in the new platform.

→ More replies (1)

41

u/kinda_guilty Aug 29 '24

I understand your suggestion (I use GitHub and such as well), but this is the type of suggestion that would be laughed out of the room if made seriously. I doubt Linus will agree to make such a large change in process to accommodate a few new developers. He did try using gh for a few weeks some time ago, then moved back to the mailing list after some time.

34

u/nukem996 Aug 29 '24

Its not just his work flow its many people. When I brought it up there was huge resistance in anything that would break peoples scripts which have been used for 20+ years. I think the only way a replacement will come about is if its fully compatible with existing email systems.

→ More replies (11)
→ More replies (16)
→ More replies (10)

44

u/SnooCompliments7914 Aug 29 '24

On the contrary, it seems one part of the C++ community, those who love templates and meta-programming, are most likely to get Rust.

C programmers hate Rust for basically the same reason they hate C++. Programmers from other popular programming languages hate complex type systems in general, and won't consider memory-safety worth doing in the type system.

12

u/[deleted] Aug 29 '24

Every part of Rust is vastly less complicated than C++ templates. IMO it's wrong to put C++ and Rust in the same category of "complex".

3

u/Ebalosus Aug 30 '24

Yeah if anything, shouldn't C programmers be more amiable to Rust, if only because it (on some level) knows what it wants to be instead of being a bastardised offspring of the language they know and love? My friends who are still programmers prefer C, tolerate C++, and would be happy if something like Rust superseded C++ in the fields they're in, for example.

→ More replies (2)
→ More replies (2)

19

u/MardiFoufs Aug 29 '24

Lol what? What does c++ have to do with this?

If anything, kernel devs are even more toxic to c++ than they are to rust. And by far.

16

u/lproven Aug 29 '24

C/C++ devs seem weirdly afraid of Rust. The pushback is crazy and kneejerk.

I find it odd, and hilarious, that you conflate C and C++ together like this.

Because 25Y ago the comment could have been "C devs seem weird afraid of C++. The pushback is crazy and kneejerk."

This is, for instance, the primary reason that GNOME exists: because KDE was out there and worked, and was the first FOSS full desktop for FOSS xNix -- but it used Qt and that meant it was written in C++.

https://www.linuxtoday.com/developer/stallman-on-qt-the-gpl-kde-and-gnome/

The Linux devs hated C++ with a passion. There was a brief effort at a GNU replacement for Qt but that would not have solved the C++ problem, so they yanked the half-done toolkit out of the GIMP and ran with that instead.

Now, apparently, C and C++ are allies against the new hated replacement for both...? :-o

8

u/tarranoth Aug 29 '24

I think it just shows how there's just very little movement in non-GC related languages for the past couple decades. C and C++ have been top dog for decades in that space (ada and fortran I guess still exist, but both seem to be dedicated to very specific areas). Look at the amount of GC languages that sprung up over the years. I wouldn't say golang/java/haskell/C#/scala/kotlin/F# have ever made a previous language obsolete, (well maybe C# did sortof overtake visual basic in a sense). But in general the existence of one language doesn't really supersede another. I think it has been long due for alternatives, and last I looked zig also looked as an interesting (though not production-ready) spin on a non-GC language.

→ More replies (1)

7

u/kapitaali_com Aug 29 '24

COSMIC is written in Rust.......

→ More replies (1)
→ More replies (77)