Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming Linux

Linux 6.1 Released With Initial Support for Rust-Based Kernel Development (lwn.net) 65

"Linus has released the 6.1 kernel," reports LWN.net — and it's the one with initial support for kernel development in Rust.

Elsewhere LWN explains the specifics of this milestone: No system with a production 6.1 kernel will be running any Rust code, but this change does give kernel developers a chance to play with the language in the kernel context and get a sense for how Rust development feels....

There are other initiatives underway, including the writing of an Apple graphics driver in the Rust language. For the initial merge into the mainline kernel, though, Linus Torvalds made it clear that as little functionality as possible should be included. So those drivers and their support code were trimmed out and must wait for a future kernel release. What is there is the support needed to build a module that can be loaded into the kernel, along with a small sample module.... Torvalds asked for something that could do "hello world" and that is what we got. It is something that can be played with, but it cannot be used for any sort of real kernel programming at this point.

That situation will, hopefully, change in the near future.

Meanwhile, Linux 6.1 also includes "support for destructive BPF programs, some significant io_uring performance improvements, better user-space control over transparent huge-page creation, improved memory-tiering support."

The Register adds: Other interesting additions include more support for the made-in-China LoongArch CPU architecture, introductory work to support Wi-Fi 7 and security fixes for some flaky Wi-Fi routines in previous versions of the kernel. There's also plenty of effort to improve the performance of Linux on laptops, and enhanced power efficiency for AMD's PC-centric RYZEN silicon.
This discussion has been archived. No new comments can be posted.

Linux 6.1 Released With Initial Support for Rust-Based Kernel Development

Comments Filter:
  • by OrangAsm ( 678078 ) on Sunday December 11, 2022 @11:22PM (#63123078)
    I'd like to prepare for this... Which port do we use for the Tetanus shot?
  • Rust (Score:2, Interesting)

    by Anonymous Coward

    What if your architecture doesn’t have the resources to build rust? Are you now at the mercy of having to cross compile?

    • They are working on a Rust front end for GCC, it isn't production ready but I would guess the assumption is that it will be done soon enough. The assumed result would then be that the Rust compiler would require the same resources as the C compiler.
      • by Anonymous Coward

        "forget the competition! our thing will be so great when it gets there!"

        We know how that one goes.

        But even if we didn't, this line of reasoning accepts a language unfit for production use into a world-wide mature been-in-production-for-decades project on some vague promises of a bunch known for caring more about appearances than about providing solid work. The language itself is still in a state of flux, there's no formal spec, nevermind a standard. Compare and contrast with C.

        poettering is already on mi

        • What does this mean? The kernel has a build process. To get Rust into the core, that build process needs to be modified to also build Rust. So that's modifying Linux a bit. After that, you want to build abstraction layers for the C interface so that is easy for Rust to access them, so it only has to be done once.

          What "bending over backwards" are you talking about?

      • by gweihir ( 88907 )

        Sooo, not even the compiler is ready at this time? I guess this will still take some time then. The over-promising and under-delivering is part of the Rust culture though. Let's see whether anybody actually doing real kernel development is impressed (so not the "diversity" people...).

        • Of course the compiler is ready. It's LLVM based that's all. The reason for having a GCC front end is because GCC supports more targets than LLVM, it will mean a single compiler can be used and GCC may (or may not) produce faster code.

          • by gweihir ( 88907 )

            Of course the compiler is ready. It's LLVM based that's all.

            Which simply means the compiler is _not_ ready...

            • It means that one compiler is ready. What is your point exactly? The compiler is not ready because support for another compiler is not ready?

              It is possible to build today with Rust infrastructure going in.

              • by gweihir ( 88907 )

                Being forced into a secondary compiling option is not "ready". Seriously.

                • Ready for what? They are releasing this as an experimental option for people to play with if they have the necessary infrastructure ready to go on their machine.

                  Of course, it is not ready, in the sense of complete, usable for production code. That wasn't the point. If you read the article, you will see that there is more infrastructure that could have been included, but was not allowed because they want to put the minimal amount in first, not to make sure it works, but to make sure it doesn't break anything

                  • I think he's bothered because it won't compile on his PDP-11, and if it doesn't do that then he considers it unfit for any use or purpose, because C was designed for the PDP-11, so everything else must be as well. And of course, all strings must be null terminated because fat pointers are an obscene waste of memory.

        • Sooo, not even the compiler is ready at this time?

          No of course not. Linus Torvalds doesn't have a clue and the only reason Linux works at all is because he reads your Slashdot comments.

    • You don't need Rust to build the kernel, only to build the optional demonstration code.

  • by The Evil Atheist ( 2484676 ) on Monday December 12, 2022 @12:26AM (#63123178)
    For the kernel proper, they're adopting a wait-and-C approach.
    • The driver code is a good candidate for Rust, because driver code is often low quality, and the drivers are well-encapsulated.

      So using Rust means that whole classes of bugs won't show up as a result of incompetent coding, in what tends to be the most incompetently written part of the kernel.

      • by tomz16 ( 992375 ) on Monday December 12, 2022 @02:26AM (#63123286)

        So using Rust means that whole classes of bugs won't show up as a result of incompetent coding, in what tends to be the most incompetently written part of the kernel.

        That remains to be seen. AFAIK you have to use unsafe rust [rust-lang.org] in order to write most interesting kernel / driver-level stuff, esp. when interfacing with previous code written in C, so the benefits people associate with the "safe" subset of the rust language won't necessarily materialize. Only time will tell how well this works in the real world.

        IMHO increasing cognitive load by adding another entire language to the kernel (i.e. right now it's JUST C11) must have some HUGE payoff in order to be worth it (i.e. keep in mind that the places where Rust has been "succesful" to date are application-level software like web-browsers where the safe subset is sufficient.... whereas even C++ has been kept out of the kernel to keep things simple for developers). This is an interesting experiment, but the expectation for Rust's benefits are set very high, so I fear for fragmentation and loss of functionality if/when it does fail to meet that bar (e.g. certain modules written in rust today may never be re-written).

        • whereas even C++ has been kept out of the kernel to keep things simple for developers

          To be more precise, C++ has been kept out because Linus hates C++ [cat-v.org]. For good reason.

          C++ is not an elegant language.

          • by Anonymous Coward

            From your link:

            Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C. — Linus, 2007

            And fifteen years later, he's willing to add "rust support" to the kernel to bring in programmers at least as crappy, and much more vocal about it.

            Where his C++ hateboner is an acceptable foible in a man in his position, his "so you kids want to throw rust at it and see if it sticks? go for it" leniency is much more likely to do re

            • his "so you kids want to throw rust at it and see if it sticks? go for it" leniency is much more likely to do real damage to the project.

              Probably not. In the worst case, it will mean some drivers don't work anymore. And while that is sad....

              Drivers that don't work for Linux? That's unheard of! No one will use it!

          • C++ is actually very elegant, and has been simplifying syntax over the past 3 releases. Most uses of template metaprogramming are completely replaceable with compile time "if constexpr", and now "consteval" functions.

            Concepts and now modules remove further pain points around the compiler. You can compile faster code faster.

            Almost all C code will still work, compiled as C++, even GCC is compiled as C++. Old C++ code will still work, and in many cases work better simply with a recompile, because the com
            • C++ is actually very elegant, and has been simplifying syntax over the past 3 releases

              Oh really? C++ is elegant now, or it was elegant 3 releases ago?

              The worst part is that C++ users think their language is efficient. It's not, and they are nincompoops.

              • C++ is elegant now.

                And it is efficient in real world loads.

                It's not my fault that you choose to base your argument on C++98.
                • C++ is neither elegant nor efficient. The only thing good about C++ is that it has features, and in more recent versions, the features are easier to use.

        • The main reason C++ is out of the kernel is because Linus has some very angry and largely speaking irrational ideas about C++.

          • His criticisms were valid at one point, but the language has moved on and fixed most of them.

            Right now, it's just people mindlessly parroting stuff he said over a decade ago, who themselves have obviously not bothered to educate themselves on the current state of C++.
            • His criticisms were valid at one point, but the language has moved on and fixed most of them.

              Some of his criticisms were right, in 1995 when he made them. There definitely was a performance hit in some cases, and, well compilers in 1995 weren't awesome.

              Some of his criticism were just flat out weird, like C++ forces you to use bad software design or some weird shit.

              • by The Evil Atheist ( 2484676 ) on Monday December 12, 2022 @07:51AM (#63123698)
                If I remember correctly, Walter Bright invented return value optimization on his way to creating a C++ compiler back in 1992. Something that C, and Linux, benefited from.

                I think what hurt C++ most back then was people thinking that the inefficient Java style OO was going to rule, and the template implementations were bad, partly due to the lack of a standard. I can understand that the informal C++ back then would force bad design.

                Someone really needs to show Linus the talk that Jason Turner gave at CppCon about implementing Pong, with modern C++17 features (and also polymorphism), to run on a C64. C++ had already matured to the point where doing the most straightforward code would lead to the most optimized code.
                • C++ had already matured to the point where doing the most straightforward code would lead to the most optimized code.

                  Sorry, but this is simply not true. You only need to watch the talk to realize how missing a "volatile" or a "const" somewhere can make your code fat, fat, fat...

                  In fact, it's hard to argue that the C++ final version is more readable than the ASM one. It's several times longer and full of black magic that is there just to make the optimizer do the right thing. And compiles v.e..r...y s.....l......o.......w........l..........y.

                  • You only need to watch the talk to realize how missing a "volatile" or a "const" somewhere

                    Writing const and volatile IS straighforward, numbnuts.

                    In fact, it's hard to argue that the C++ final version is more readable than the ASM one.

                    What a load of shit.

                    • If C++ were as elegant as you claim, then why do you even need these at all? In Rust, everything is const unless you specifically opt out, and way more often than not, variables should be const. And volatile just has kludge written all over it.

                    • Because of backwards compatibility. Sorry, but not all of us are slapdash about breaking things.

                      And do you even know why volatile exists, or are you just a stupid Rustacean who doesn't understand why you need volatile to interact with hardware?

                      Even Rust needs volatile, you nonce: https://docs.rs/volatile/lates... [docs.rs]
                    • Because of backwards compatibility. Sorry, but not all of us are slapdash about breaking things.

                      You realize you just countered your own argument, right? This is exactly what everybody is talking about: C++ has tons of baggage, which is exactly WHY it is irrevocably a big mess. This is yet another example of that.

                      And do you even know why volatile exists, or are you just a stupid Rustacean who doesn't understand why you need volatile to interact with hardware?

                      Even Rust needs volatile, you nonce:

                      No, rust doesn't *need* that. If it did, it would be a keyword. And therein lies the rub: Just like exceptions and mutable variables, C++ developers overuse and abuse the hell out of it. Look at that crate on crates.io. Notice how few other crates actually use it? And yet, it's an actual keywo

                    • You realize you just countered your own argument, right?

                      No, because backwards compatibility isn't evil, dipshit. And "const" is barely noticeable. Only a desperate hack with no argument would try to make "const' an argument against elegance. Yours is a shitty, desperate argument.

                      No, rust doesn't *need* that.

                      No, Rust just needs an underlying C++ compiler to handle all that for it. Without C++, Rust is nothing.

                      Just like exceptions and mutable variables, C++ developers overuse and abuse the hell out of it.

                      No they don't. They actually don't. They're actually used sparingly. You're just a shit programmer and blame your misuses of them on the language. You're just a shit programmer who's ob

                    • Having thought about your reply more... you really are a fucking tool.

                      In the beginning, C did not have const. In fact, no languages had the concept of const. Bjarne Stroustrup invented const as one of the first things he did for C++, back in the 80s.

                      To keep compatibility with C, C++ didn't make things const by default, because it would have slowed adoption of C++. C++'s compatibility with C was important because it allowed people to migrate to a safer language without people worrying about breaking th
                    • And as you seem to believe, more keywords means more elegance!

                      C++11 added the keyword constexpr. C++14 and C++17 made the keyword useful in more contexts.

                      The end result: a reduction in the use of template metaprogramming.

                      Adding one keyword literally eliminated the need for millions of lines of code.

                      You're such a fucking retard it's not funny. You are incapable of understanding that, yes, you can add new features (which may involve new keywords) that actually reduces cruft. But without breaking backwards compatibility.

                      GROW THE FUCK UP, you nonce.

                    • No, because backwards compatibility isn't evil, dipshit. And "const" is barely noticeable. Only a desperate hack with no argument would try to make "const' an argument against elegance. Yours is a shitty, desperate argument.

                      It's called line noise dude. Basically your code is super verbose. That's not elegant. It wasn't random, I mentioned that specifically because it's on topic.

                      No, Rust just needs an underlying C++ compiler to handle all that for it. Without C++, Rust is nothing.

                      Actually that's just the back end. The front end compiles to the IR, and it's written in Rust.

                      No they don't. They actually don't. They're actually used sparingly.

                      No, they're used often, in places where they really don't belong. Throwing exceptions for a missing file is super common, and really unnecessary.

                      You should stick to your safespace programming.

                      That's actually a good idea for anybody to do. Only use unsafe when absolutely necessary. Most of the time it's unne

                    • It's called line noise dude. Basically your code is super verbose.

                      "const" is verbose? Okay, leave the programming to adults.

                      Actually that's just the back end.

                      Yeah, which is the important part. Anyone can write a parser.

                      No, they're used often, in places where they really don't belong. Throwing exceptions for a missing file is super common, and really unnecessary.

                      Yeah... no.

                      Demonstrates it quite well. Popping a stack frame is quick, unwinding is not.

                      Unwinding one stack frame is, wait for it: the same as popping one stack frame. Destructors run. "Stack unwinding" is just popping multiple stack frames. Just as you would if you were passing error values up the call chain, numbnuts.

                      "Stack unwinding" is just code generated by the compiler to do the "run the destructors on function exit". Exactly the same as the manual process

                    • LOL you keep shouting "incompetence" while you keep making dumb statements. Honestly I have no idea how you get the time to write such lengthy, angry rants. My guess is that unlike me, you're unemployed. Which explains a lot, actually.

                      Then again, theevilanalinguist, if I had a mouth full of poo, such as you, I'd be pissed too.

                    • Says the so-called "security researcher" who doesn't know how stacks and RAII works, or anything about the last 40 years of programming languages. Seriously, I have no idea how someone could be so uninformed about how exceptions work and still have such a strong and wrong opinion.

                      Nice try in attempting to goad personal information out of me. My guess is you're one the unhinged Anonymous Cowards on this site who spends time trying to doxx people.

                      So yes, I may, or may not, be unemployed. I may, or may n
                    • Seriously? I even stressed the difference and yet...

                      Dude...

                      Pull your tongue out of the butt for once so that you can actually read my posts rather than just going on another one of your trademark aimless lunatic rants.

                      In fact, you should do that everywhere. It's really rich that you try to tell me what I don't know when you always try to speak authoritatively about what rust is and is not, only to face embarrassment when people like me come around to correct you.

                      Reading would have helped you that time you l

                    • You stressed that you didn't understand that "stack unwinding" multiple stack frames is just popping multiple stack frames, just like returning from multiple level of function calls.

                      Keep trying, bootcamp pity hire.
                    • Dude did you even read the link I posted? There's definitely a difference both in implementation and cost.

                      Also, unlike you, I've never actually done a coding boot camp. In fact, I'm entirely self taught, and basically only started doing it three years ago. Which is pretty impressive considering I went from zero to being within the top 10% of what all software developers earn in such a short period of time. Which is probably why you're so damn pissed off. You spent your entire career doing this and I've alre

                    • Yes. And I definitely understood it more than you. If you think there's any essential difference between stack unwinding multiple frames, from returning up through multiple levels of function calls, then you are seriously incapable of understanding it.

                      Self taught? No wonder you fucking suck. You didn't know about signals and setjmp. You didn't know C++ has a deprecation strategy (for both keywords and libraries). You didn't know the history of const. You really don't seem to understand how Rust uses RAII
                    • Self taught? No wonder you fucking suck.

                      Well, let me tell you why I'm self taught. Basically at a previous job, we hired a consulting company to input data for us algorithmically. The company we hired was supposedly at the top of their game, and the people who did the work had over 20 years of experience. Problem is, they fucked it up. Badly. And they did it in such a way that there was no clear way to fix it short of going through all 30k accounts by hand. Unfortunately, it was something that we just had to put up with. I took it upon myself to

                    • we hired a consulting company

                      I love how that THIS is what gives you your undeserved level of confidence. You really haven't been in the industry long, have you?

                      Consulting companies are not regulated, just like the entire industry, and you can never really tell who is talking a good game vs those who make things work. Sounds like you hired a dud.

                      For example, some companies market themselves as doing data mining and AI, but it turns out they actually just use one messy Excel spreadsheet. Especially worse when the Excel spreadsheet

                    • You really haven't been in the industry long, have you?

                      IT in general? About 8 years.

                      Sounds like you hired a dud.

                      Wasn't my decision.

                      You're so fucking naive in this industry that you think you're hot shit because you did better than a consulting company

                      I don't think I'm hot shit at all actually, I just know I'm better than you. Go look at my post history, I openly admit to lots of stuff that I don't know about.

                      someone will discover that you've fucked one thing up royally.

                      I've already made mistakes here and there, but I haven't caused any kind of serious outage or anything like that. I'm always very cautious about what I do, some people say too cautious.

                      Yeah, big surprise. You get paid a lot because you live in an expensive city, in an expensive part of the country.

                      Actually I've only been here for three months, and I anticipate leaving in another three. One of two possible location

                    • Actually I've only been here for three months

                      Okay, irrelevant. They pay you like they pay other people who live in that city. Nothing to do with how much your "programming skill" is actually worth.

                      Actually, it does.

                      No, numbnuts. Your own claim was that being paid top 10% says something about your supposed skill. No, it only says something about your location.

                      Unlike you, he knows that at some point there's some stuff that is beyond obsolete,

                      He's still programming in C. Not Rust. According to you, he should have ditched C, because of const and volatile, dumbass.

                      If that's the case, then why the hell are you constantly waging them?

                      You're the one who jumped on this thread with an axe to grind. I started out with a joke. Yo

                    • Eh...whatever benefits you've got, I guarantee you I've got better ones.

                      Way to miss the point. The point is my employer doesn't have to pay me nearly as much because taxes already paid for it.

                      Your "top 10%" salary is just padded because of where the company is, and your country's situation.

                      And so you linked to an irrelevant slashdot post because...?

                      Because you called yourself a cybersecurity developer, and that post, and replies, talks about the supposed skill of certain cybersecurity people. You sound like one of them.

                      But like I said, you can keep your delusion that your "top 10%" salary is about your skill.

                    • Okay, irrelevant. They pay you like they pay other people who live in that city.

                      No, they don't.

                      No, numbnuts.

                      How original... Anyways, you're wrong. I'm only here temporarily, and they don't alter your pay based on where you are. When I started, I was in a much cheaper area.

                      He's still programming in C. Not Rust. According to you, he should have ditched C, because of const and volatile, dumbass.

                      No, that's not what I said. Not now, nor previously. You don't even remember why I replied to you, do you? This whole thing started because you're trying to argue that broke ass C++ is somehow elegant, and I'm saying otherwise. Those are part of why, but even so, those by themselves are not a reason to ditch a language. Nor did I

                    • I'm only here temporarily, and they don't alter your pay based on where you are.

                      I said they pay based on where they are, dumbass.

                      It's okay. You just keep to your fantasy that your pay is directly related to your programming skill.

                      Nor did I advocate any such thing.

                      Yeah, you did. You called backwards compatibility "technical debt". You literally advocated that old code needs to be rewritten because it is technical debt. For absolutely no other reason than because it's old.

                      So does Rust.

                      No Rust code is decades old. In fact, it's barely reached the age where C++ started to require proper standardization and, shock horror, backwards c

                    • I said they pay based on where they are, dumbass.

                      That really doesn't mean anything because they're spread throughout the US. In fact, they have a very big presence in both of the other areas I mentioned.

                      Yeah, you did. You called backwards compatibility "technical debt".

                      I didn't call backwards compatibility technical debt. Go read it again. Tongue out of the butt this time. I specifically mentioned that using long obsoleted technologies is technical debt, NOT compatibility in an of itself. This is because as you adopt new technologies, you "pay interest" on that debt in the form of having higher labor costs (as fewer deve

                • by caseih ( 160668 )

                  Certainly a very impressive talk and demonstration. I've watched it before but it was good to re-watch it. However I'm left with very conflicted feelings. On the one hand it's truly impressive what the compiler can do, on the other hand I don't actually see any of that as simplifying C++. In fact it adds source code complexity and requires significant skill to know how and when to use these newer features including constexpr, etc. I wouldn't exactly call what he did straight forward. Powerful stuff, yes

                  • I don't see how his code WASN'T straightforward. There was NO magic stuff. He used virtual inheritance just like normal. No metaprogramming. No tricks.

                    The only non-straightforward thing was a one-to-one x86 to C64 asm transpiler because there wasn't one for C++17 yet. The C++17 code he wrote was much less complex than even C++98.
                • If I remember correctly, Walter Bright invented return value optimization on his way to creating a C++ compiler back in 1992. Something that C, and Linux, benefited from.

                  That's before my time :)

                  I do remember gcc did some somewhat inefficient things with register allocation for C++ back in the mid 90s. Also, CPUs were less good at branch prediction. C++'s (well, the compilers) style of OO uses the vtable pointer, which is much more memory efficient but requires OK branch prediction. It's much better for mode

            • But the nasty old edge and corner cases were never removed from C++. They can't be, without breaking backward compatibility. AFAIK (correct me if I'm wrong) you can't disable all of them with compiler flags.

              So, you can write newer C++ that uses these newer features designed to make it a bit safer and saner. But nothing other than code review will stop you from still using the older dialects of C++ that were poorly thought out.

              That's time and effort that could instead be invested in writing good C (and/or

        • by pavon ( 30274 )

          So far the largest attempt at writing a Linux driver in Rust has been the Asahi Apple M1 GPU driver. That has a few hundred lines of unsafe code* out of about ten thousand lines total. The author said this has both decreased the number of memory corruption bugs that they would expect in a new driver this size and made them much easier to track down when they did occur.

          * Not counting common rust wrapper code not written for this driver. There are a few thousand lines of unsafe code there, not all of which ar

        • ... certain modules written in rust today may never be re-written

          Maybe it is the idea, that future driver modules written once in Rust won't have to be rewritten every time. The kernel would then serve a purpose similar to a hardware abstraction layer viz the driver modules. Rust-based drivers/driver modules and the Linux kernel would interface with one another, and maybe other kernels with future support for Rust would, too. If other operating systems join in, then that alone would increase the surface area of hardware compatibility and the variability of metal for Lin

  • I don't really have a horse in this race, but it sounds to me like Rust is a little difficult to wrap one's head around. From a non-technical perspective, I'd be worried that this cuts way down on those who are able to work on such code. "You have to learn Rust first..." versus the easier barrier-to-entry of C.

The Tao is like a glob pattern: used but never used up. It is like the extern void: filled with infinite possibilities.

Working...