LWN: Comments on "Using Rust for kernel development" https://lwn.net/Articles/870555/ This is a special feed containing comments posted to the individual LWN article titled "Using Rust for kernel development". en-us Fri, 19 Sep 2025 10:22:49 +0000 Fri, 19 Sep 2025 10:22:49 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Using Rust for kernel development https://lwn.net/Articles/872419/ https://lwn.net/Articles/872419/ NAR <i>In my experiance dual language is really rare. The only direct experiances I have doing this has ended up being pretty horrible in the interfacing layer.</i> <p> Interesting. I thought it's quite common - have the frontend in Java or Javascript, the backend in C++ or Elixir or whatever, throw in some SQL for the stored procedures, some Python for test glue, maybe a Perl binding... Even if there are separate teams working on the frontend and backend, they might still look into each others code from time to time... I didn't need to be a Python expert to add a testcase or a Javascript expert to figure out the parameters passed to the backend. Granted, there are few projects needing the level of C expertise as the Linux kernel, so maybe being an expert in two languages might be harder - but I don't think (maybe C++ is the big exception, that's a horrible complicated language). Sun, 10 Oct 2021 14:42:50 +0000 Using Rust for kernel development https://lwn.net/Articles/871482/ https://lwn.net/Articles/871482/ piexil <div class="FormattedComment"> For real, it was completely unnecessary, and it&#x27;s so smug. People also already do things similar to fixing transpiled code in their freetime. (reverse engineering decompiled assembly to c like the super mario 64 decomp comes to mind) <br> </div> Thu, 30 Sep 2021 21:53:50 +0000 Using Rust for kernel development https://lwn.net/Articles/871303/ https://lwn.net/Articles/871303/ mpr22 <div class="FormattedComment"> (And, of course, it turns the rest into process-local data structure corruption. Which could still be disastrous when the program has control of a DMA-capable peripheral device and your IOMMU capabilities are insufficient...)<br> </div> Thu, 30 Sep 2021 00:06:42 +0000 Using Rust for kernel development https://lwn.net/Articles/871298/ https://lwn.net/Articles/871298/ mpr22 <div class="FormattedComment"> Writing in Rust turns many kinds of memory safety violation into compile-time errors, meaning that you have to fix them before you can start testing the code.<br> <p> Running in user-space turns some subset of memory safety violations, which partially overlap with those that Rust turns into compile-time errors, into SIGSEGVs instead of kernel data structure corruption.<br> </div> Thu, 30 Sep 2021 00:03:52 +0000 Using Rust for kernel development https://lwn.net/Articles/871296/ https://lwn.net/Articles/871296/ MrWim <div class="FormattedComment"> In case you&#x27;re not already aware there&#x27;s the c2rust project: <a href="https://c2rust.com/">https://c2rust.com/</a> . The idea was that it does an automatic conversion for you to unsafe rust and then provides tools to help with conversion to idiomatic rust, and to help confirm that the conversion was faithful.<br> <p> I can thoroughly recommend the blog series on the same: <a href="https://immunant.com/blog/">https://immunant.com/blog/</a> and the wiki contains a discussion of some of the limitations of the approach: <a href="https://github.com/immunant/c2rust/wiki/Known-Limitations-of-Translation">https://github.com/immunant/c2rust/wiki/Known-Limitations...</a> . It&#x27;s sufficiently advanced to allow transpiling Quake 3 with only minor changes required to the C source.<br> <p> From looking at the github history it seems like the project has slowed over the last year or two. I don&#x27;t know of its current state.<br> <p> (This isn&#x27;t an endorsement of the approach, just a pointer to it)<br> </div> Wed, 29 Sep 2021 23:47:39 +0000 Using Rust for kernel development https://lwn.net/Articles/871292/ https://lwn.net/Articles/871292/ lwnli <div class="FormattedComment"> read somewhere else. wonder if writing it in user space gives the same benefit as writing it in Rust.<br> </div> Wed, 29 Sep 2021 21:42:24 +0000 Using Rust for kernel development https://lwn.net/Articles/871180/ https://lwn.net/Articles/871180/ excors <div class="FormattedComment"> <font class="QuotedText">&gt; I don&#x27;t know if there is any transpilation in the &quot;original&quot; Mozilla, but the HTML (5, at the time) parser was converted from Java to C++ - <a href="https://johnresig.com/blog/html-5-parsing/">https://johnresig.com/blog/html-5-parsing/</a></font><br> <p> The HTML5 parser is a special case since it&#x27;s a large amount of mostly very repetitive code, defining a complex state machine to turn characters into tokens and another to turn tokens into a DOM tree. (There&#x27;s enough special cases and weird rules, for backward compatibility reasons, that it&#x27;s not very practical to implement the state machines declaratively - it&#x27;s easier to write as imperative code. Plus the code closely mirrors the structure of the HTML5 specification, which makes it easier to verify that the spec and implementation are consistent.)<br> <p> Since it&#x27;s so repetitive, it&#x27;s relatively easy to mechanically translate between languages. And I think in this case the transpiler was custom-written for the HTML5 parser, and the Java version of the code was modified to be easy to transpile. E.g. compare &quot;startTag&quot; in Java (<a href="https://hg.mozilla.org/mozilla-central/diff/8b5103cb12a6b62558ba6ad64109f50bb66bd820/content/html/parser/javasrc/TreeBuilder.java#l1.1383">https://hg.mozilla.org/mozilla-central/diff/8b5103cb12a6b...</a>) and C++ (<a href="https://hg.mozilla.org/mozilla-central/diff/8b5103cb12a6b62558ba6ad64109f50bb66bd820/parser/html/nsHtml5TreeBuilder.cpp#l1.563">https://hg.mozilla.org/mozilla-central/diff/8b5103cb12a6b...</a>): the Java has some explicit &quot;// [NOCPP[&quot; markers for sections to omit from the C++, function calls like err() are deleted from the C++ (because the Java version was meant for use in a validator, which needs to report parse errors with as much detail as possible, whereas a browser doesn&#x27;t), enum values are renamed to Mozilla&#x27;s naming convention, string literals are replaced with global constants, etc, so there&#x27;s a lot of translation rules specific to this codebase.<br> <p> This is very different from general-purpose transpiling of arbitrary code that wasn&#x27;t designed for it.<br> </div> Wed, 29 Sep 2021 10:41:14 +0000 Using Rust for kernel development https://lwn.net/Articles/871176/ https://lwn.net/Articles/871176/ Fowl <div class="FormattedComment"> I don&#x27;t know if there is any transpilation in the &quot;original&quot; Mozilla, but the HTML (5, at the time) parser was converted from Java to C++ - <a href="https://johnresig.com/blog/html-5-parsing/">https://johnresig.com/blog/html-5-parsing/</a><br> </div> Wed, 29 Sep 2021 09:33:04 +0000 Using Rust for kernel development https://lwn.net/Articles/871174/ https://lwn.net/Articles/871174/ farnz <p>Have you got a reference for this? I can trace the core of Firefox's codebase back to Netscape 1.0, which predates Java, so if a transpiler was involved, it was during the rewrite. Wed, 29 Sep 2021 09:13:45 +0000 Using Rust for kernel development https://lwn.net/Articles/871153/ https://lwn.net/Articles/871153/ maxfragg <div class="FormattedComment"> you might be surprised to learn, that mozillas codebase started with transpiler-output, as what later became the mozilla suit and in turn firefox had a transpiled java core.<br> </div> Wed, 29 Sep 2021 06:29:43 +0000 Using Rust for kernel development https://lwn.net/Articles/871126/ https://lwn.net/Articles/871126/ rahulsundaram <div class="FormattedComment"> <font class="QuotedText">&gt; If drivers are encouraged to be implemented in user space, what benefit does writing drivers in Rust bring about?</font><br> <p> The article doesn&#x27;t talk about user space drivers. Where are you getting that from?<br> </div> Tue, 28 Sep 2021 21:57:41 +0000 Using Rust for kernel development https://lwn.net/Articles/871122/ https://lwn.net/Articles/871122/ lwnli <div class="FormattedComment"> If drivers are encouraged to be implemented in user space, what benefit does writing drivers in Rust bring about?<br> </div> Tue, 28 Sep 2021 21:03:14 +0000 Using Rust for kernel development https://lwn.net/Articles/871103/ https://lwn.net/Articles/871103/ PaulMcKenney <div class="FormattedComment"> And that reuse of the backend code is the challenge!<br> <p> At the informal meeting called out in the article, I committed to write a blog series on the specific topics that I am concerned about. As Dan Frye was wont to say, &quot;It should be good clean fun.&quot; ;-)<br> </div> Tue, 28 Sep 2021 17:24:17 +0000 Using Rust for kernel development https://lwn.net/Articles/871101/ https://lwn.net/Articles/871101/ pbonzini <div class="FormattedComment"> <font class="QuotedText">&gt; It might be unfair to say that the Kernel memory model is x86, but there&#x27;s a heavy overlap on the assumptions Linus Torvalds made 30 years ago.</font><br> <p> I think that&#x27;s quite incorrect since:<br> <p> * any x86-based memory model would have serious problem on weakly-ordered architectures, and also would have serious problems with optimizations that do not respect the TSO (total store ordering) model that x86 uses.<br> <p> * I might be wrong on this, but the first architecture for which Linux supported SMP was either SPARC or Alpha, almost certainly not x86<br> <p> Right now, the Rust memory model _is_ the C/C++ model since it just reuses the same backend code.<br> </div> Tue, 28 Sep 2021 16:40:23 +0000 Using Rust for kernel development https://lwn.net/Articles/871098/ https://lwn.net/Articles/871098/ linusw <div class="FormattedComment"> As &quot;fake Linus&quot; I can just acknowledge the protocol here: I am happy about Rust when done right (read: with true grit) and don&#x27;t mind to go first.<br> <p> However during review I did point out that the security hurdles that Rust can help to solve are not in drivers, and I pointed to filesystems and suggested that the developers look at reimplementing the (then out-of-tree) ksmbd in Rust. ksmbd was then merged unbeknownst to me and my worries confirmed to be true as some out-of-bounds bugs (which are impossible in Rust) surfaced immediately.<br> </div> Tue, 28 Sep 2021 16:04:44 +0000 Using Rust for kernel development https://lwn.net/Articles/871062/ https://lwn.net/Articles/871062/ k3ninho <div class="FormattedComment"> <font class="QuotedText">&gt;Thomas Gleixner ... is worried, though, about &quot;the blank page where the memory model should be&quot;. Ojeda ... encouraged Paul McKenney that this is the best time to go to the Rust community and tell them how things could be.</font><br> <p> I&#x27;m a fan of cross-pollination and have huge respect for Paul McKenney&#x27;s ability to build consensus on a way forward while also teaching the lessons of the past that went wrong. It might be unfair to say that the Kernel memory model is x86, but there&#x27;s a heavy overlap on the assumptions Linus Torvalds made 30 years ago. I might put a slots on the bingo card that: other memory models do it better; Rust wants to learn those lessons; mismatch with the LKMM when it comes to the essential bikeshedding.<br> <p> K3n.<br> </div> Tue, 28 Sep 2021 14:46:53 +0000 Using Rust for kernel development https://lwn.net/Articles/871061/ https://lwn.net/Articles/871061/ jgg <div class="FormattedComment"> Just making C compile in a C++ compiler is not at all what I mean by upgrade. Proper C++11 code looks and operates very differently from C code. Human led, machine assisted incremental improvement is required to get from C to C++11 stuff. This is things like converting to use unique_ptr/smart_ptr, changing open coded containers into STL stuff, relying on the language to do cleanup, using move semantics, references, etc/etc. This is where the code becomes safer and more understandable.<br> <p> My point is there is a proven path from C code to high quality C++11 code that is incremental and auditable (and a wack of human work). It starts with a lightweight &#x27;transpile&#x27; to get C code into the C++ compiler in the first place, and no, it doesn&#x27;t completely destroy the readability of the code base.<br> <p> To my mind this should be the gold standard. This approach to add Rust parallel to C without any sane migration path is not. The fact that C to Rust, to even get started on the human-led incremental improvement, is basically impossible is not inherent. It comes from the deliberate design of Rust.<br> <p> Despite Al&#x27;s virtrol, I think there is merit in exploring what an ideal language upgrade for the kernel would be like - at least we can understand how far away this Rust proposal is.<br> </div> Tue, 28 Sep 2021 13:41:43 +0000 Using Rust for kernel development https://lwn.net/Articles/871060/ https://lwn.net/Articles/871060/ alonz Upgrading C to C++ (and C++03 to C++11) is somewhat of a joke; the language is generally 99.9% identical, and the only "conversion" required is often just to replace identifiers which conflict with keywords in the other language with something else. (And even then, in some such "uplifted" codebases I have seen, the resulting identifiers were jarring and clearly not what a human programmer would choose to use.) <p>Conversion between languages with larger semantic differences - such as the case with Rust - would indeed be a feat worthy of a Nobel-prize-equivalent. And that's even <em>before</em> you try to care about readability of the resulting code. (I had myself written two such "transpilers" in my career; both were <em>very</em> special-purpose, targeting very limited code-bases, and both produced code that was nearly impossible to maintain.) Tue, 28 Sep 2021 12:41:08 +0000 Using Rust for kernel development https://lwn.net/Articles/871056/ https://lwn.net/Articles/871056/ dvrabel <div class="FormattedComment"> And kernel maintainers wonder why they have trouble attracting new developers and maintainers. Only the last sentence has actual, valid content and the rest is entirely unnessesary vitriol.<br> <p> FWIW, this sort of toxic response and culture is why I&#x27;m highly unlikely to ever be a kernel subsystem maintainer again.<br> </div> Tue, 28 Sep 2021 09:39:34 +0000 Using Rust for kernel development https://lwn.net/Articles/871050/ https://lwn.net/Articles/871050/ tux3 <div class="FormattedComment"> Mozilla seems to think having two languages in the same codebase is reasonable. Given Rust was created at Mozilla and used to ship major Firefox components, I imagine they have thought about this quite a bit.<br> <p> Unsurprisingly, Mozilla is not trying to convert their existing C++ codebase into transpiler output.<br> </div> Tue, 28 Sep 2021 07:21:36 +0000 Using Rust for kernel development https://lwn.net/Articles/871047/ https://lwn.net/Articles/871047/ jgg <div class="FormattedComment"> Who said core parts? I said obsolete drivers. I said incremental change.<br> <p> Advocating for a permentant state of two completely different languages bridged together with a vast hodpodge of bindgen and hand written code only a rare expert can understand is barely a better outcome.<br> <p> And yes, I know C to Rust-as-it-is-today is halfway insane, but come on, lets at least be open to imagining there is some outcome out there where we could have a language improvement and not end up with a permanent dual-language mess.<br> <p> There is historical context for upgrading codebases in-place, many C to C++ and C++03 to C+11 uplifts have gone down an incremental upgrade path over the last 20 years without hitting your doomsday prophecy. Mechanically fix enough to be compilable in the new standard, then incremental passes to update high value areas. Programs like clang-tidy and coccinelle are even a proven path for machine guided incremental improvement.<br> <p> In my experiance dual language is really rare. The only direct experiances I have doing this has ended up being pretty horrible in the interfacing layer.<br> </div> Tue, 28 Sep 2021 02:13:36 +0000 Using Rust for kernel development https://lwn.net/Articles/871045/ https://lwn.net/Articles/871045/ viro <div class="FormattedComment"> Lovely. When you are done with your &quot;convert not quite safe C into Rust, without turning it into completely undebuggable mess&quot; tool (and after having received the Nevanlinna Prize, richly deserved for such achievement), make sure to contact us mere mortals. Until then, comp.lang.advocacy and alt.sex.masturbation are over -&gt; that way.<br> <p> And no, it&#x27;s not too harsh - anyone who suggest that automated transliteration from one language to another can improve anything is delusional and ignorant in the best case. It&#x27;s not even &quot;one can write Fortran in any language&quot; (and I&#x27;ve seen the results of that), it&#x27;s &quot;replace the core parts of the kernel with a mess of horribly unidiomatic Rust, produced by automated conversion with unknown amount of bugs introduced by that and zero odds of discovering them in the resulting unreadable obsce^Wcodebase&quot;.<br> </div> Tue, 28 Sep 2021 00:39:37 +0000 Using Rust for kernel development https://lwn.net/Articles/871044/ https://lwn.net/Articles/871044/ jgg <div class="FormattedComment"> I hope the outcome of all of this is a widespread recongition that C is no longer a great language to write the kind of software the Kernel has turned out to be.<br> <p> I also hope sanity prevals and top level kernel contributors are not required to be experts in two languages. It is hard to reconcile Linus suggesting we need a 10:1 submitter/maintainer ratio while making it ridiculously hard to actually train a kernel maintainer. I&#x27;d put up with this for ~5 years, but not forever.<br> <p> Which suggests to me any path to fixing the problem requires a long-term outcome where all of the kernel is in a single language.<br> <p> For instance I&#x27;d be much happier if someone was working on something like the python 2to3 tool with the idea of mechnically converting entire swaths of the kernel into rust. Eg lets make the *entire* GPIO subsystem rust/etc. Yes, the conversion may be riddled with unsafe, but at least it is one language and can get fixed in an incremental way. IMHO this is a fine way to let old HW drivers ride out into the sunset.<br> <p> </div> Mon, 27 Sep 2021 23:36:02 +0000 Using Rust for kernel development https://lwn.net/Articles/870620/ https://lwn.net/Articles/870620/ pbonzini <div class="FormattedComment"> <font class="QuotedText">&gt; He is worried, though, about &quot;the blank page where the memory model should be&quot;.</font><br> <p> I should really write the &quot;C11 memory model for kernel programmers&quot; article that I&#x27;ve been mulling over for a while. The same issues pretty much occur with Rust, as Miguel pointed out.<br> </div> Mon, 27 Sep 2021 17:33:56 +0000