logo

drewdevault.com

[mirror] blog and personal website of Drew DeVault git clone https://hacktivis.me/git/mirror/drewdevault.com.git

2024-08-30-Rust-in-Linux-revisited.md (8337B)


  1. ---
  2. title: Rust for Linux revisited
  3. date: 2024-08-30
  4. ---
  5. > *Ugh. Drew's blogging about Rust again.*
  6. -- You
  7. I promise to be nice.
  8. Two years ago, seeing the Rust-for-Linux project starting to get the ball
  9. rolling, I wrote "[Does Rust belong in the Linux kernel?][0]", penning a
  10. conclusion consistent with [Betteridge's law of headlines][1]. Two years on we
  11. have a lot of experience to draw on to see how Rust-for-Linux is actually playing
  12. out, and I'd like to renew my thoughts with some hindsight -- and more
  13. compassion. If you're one of the Rust-for-Linux participants burned out or
  14. burning out on this project, I want to help. Burnout sucks -- I've been there.
  15. [0]: https://drewdevault.com/2022/10/03/Does-Rust-belong-in-Linux.html
  16. [1]: https://en.wikipedia.org/wiki/Betteridge's_law_of_headlines
  17. The people working on Rust-for-Linux are incredibly smart, talented, and
  18. passionate developers who have their eyes set on a goal and are tirelessly
  19. working towards it -- and, as time has shown, with a great deal of patience.
  20. Though I've developed a mostly-well-earned reputation for being a fierce critic
  21. of Rust, I do believe it has its place and I have a lot of respect for the work
  22. these folks are doing. These developers are ambitious and motivated to make an
  23. impact, and Linux is undoubtedly the highest-impact software in the world, and
  24. in theory Linux is enthusiastically ready to accept motivated innovators into
  25. its fold to facilitate that impact.
  26. At least in theory. In practice, the Linux community is the wild wild west, and
  27. sweeping changes are infamously difficult to achieve consensus on, and this is
  28. by far the broadest sweeping change ever proposed for the project. Every
  29. subsystem is a private fiefdom, subject to the whims of each one of Linux's
  30. 1,700+ maintainers, almost all of whom have a dog in this race. It's herding
  31. cats: introducing Rust effectively is one part coding work and ninety-nine parts
  32. political work -- and it's a lot of coding work. Every subsystem has its own
  33. unique culture and its own strongly held beliefs and values.
  34. The consequences of these factors is that Rust-for-Linux has become a burnout
  35. machine. My heart goes out to the developers who have been burned in this
  36. project. It's not fair. Free software is about putting in the work, it's a
  37. classical do-ocracy... until it isn't, and people get hurt. In spite of my
  38. critiques of the project, I recognize the talent and humanity of everyone
  39. involved, and wouldn't have wished these outcomes on them. I also have sympathy
  40. for many of the established Linux developers who didn't exactly want this on
  41. their plate... but that's neither here nor there for the purpose of this post,
  42. and any of those developers and their fiefdoms who went out of their way to make
  43. life *difficult* for the Rust developers above and beyond what was needed to
  44. ensure technical excellence are accountable for these shitty outcomes.[^1]
  45. So where do we go now?
  46. Well, let me begin by re-iterating something from my last article on the
  47. subject: "I wish [Rust-for-Linux] the best of luck and hope to see them
  48. succeed". Their path is theirs to choose, and though I might advise a moment to
  49. rest before diving headfirst into this political maelstrom once again, I support
  50. you in your endeavours if this is what you choose to do. Not my business. That
  51. said, allow me to humbly propose a different path for your consideration.
  52. [^1]: Yes, I saw that video, and yes, I expect much better from you in the
  53. future, Ted. That was some hostile, toxic bullshit.
  54. Here's the pitch: a motivated group of talented Rust OS developers could build a
  55. Linux-compatible kernel, from scratch, very quickly, with no need to engage in
  56. LKML politics. You would be astonished by how quickly you can make meaningful
  57. gains in this kind of environment; I think if the amount of effort being put
  58. into Rust-for-Linux were applied to a new Linux-compatible OS we could have
  59. something production ready for some use-cases within a few years.
  60. Novel OS design is hard: projects like [Redox][2] are working on this, but it
  61. will take a long time to bear fruit and research operating systems often have to
  62. go back to the drawing board and make major revisions over and over again before
  63. something useful and robust emerges. This is important work -- and near to my
  64. heart -- but it's not for everyone. However, making an OS which is based on a
  65. proven design like Linux is *much* easier and can be done very quickly. I worked
  66. on my own novel OS design for a couple of years and it's still stuck in design
  67. hell and badly in need of being rethought; on the other hand I wrote a passable
  68. Unix clone alone in less than 30 days.
  69. [2]: https://www.redox-os.org/
  70. Rust is a great fit for a large monolithic kernel design like Linux. Imagine
  71. having the opportunity to implement something like the dcache from scratch in
  72. Rust, without engaging with the politics -- that's something a small group of
  73. people, perhaps as few as one, could make substantial inroads on in a short
  74. period of time taking full advantage of what Rust has on offer. Working towards
  75. compatibility with an existing design can leverage a much larger talent pool
  76. than the very difficult problem of novel OS design, a lot of people can manage
  77. with a copy of the ISA manual and a missive to implement a single syscall in a
  78. Linux-compatible fashion over the weekend. A small and motivated group of
  79. contributors could take on the work of, say, building out io_uring compatibility
  80. and start finding wins fast -- it's a lot easier than designing io_uring from
  81. scratch. I might even jump in and build out a driver or two for fun myself, that
  82. sounds like a good opportunity for me to learn Rust properly with a fun project
  83. with a well-defined scope.
  84. Attracting labor shouldn't be too difficult with this project in mind, either.
  85. If there was *the* Rust OS project, with a well-defined scope and design (i.e.
  86. aiming for Linux ABI compatibility), I'm sure there's a lot of people who'd jump
  87. in to stake a claim on some piece of the puzzle and put it together, and the
  88. folks working on Rust-for-Linux have the benefit of a great deal of experience
  89. with the Linux kernel to apply to oversight on the broader design approach.
  90. Having a clear, well-proven goal in mind can also help to attract the same
  91. people who want to make an impact in a way that a speculative research project
  92. might not. Freeing yourselves of the LKML political battles would probably be a
  93. big win for the ambitions of bringing Rust into kernel space. Such an effort
  94. would also be a great way to mentor a new generation of kernel hackers who are
  95. comfortable with Rust in kernel space and ready to deploy their skillset to the
  96. research projects that will build a next-generation OS like Redox. The labor
  97. pool of serious OS developers badly needs a project like this to make that
  98. happen.
  99. So my suggestion for the Rust-for-Linux project is: you're burned out and that's
  100. awful, I feel for you. It might be fun and rewarding to spend your recovery
  101. busting out a small prototype Unix kernel and start fleshing out bits and pieces
  102. of the Linux ABI with your friends. I can tell you from my own experience doing
  103. something very much like this that it was a very rewarding burnout recovery
  104. project for me. And who knows where it could go?
  105. Once again wishing you the best and hoping for your success, wherever the path
  106. ahead leads.
  107. <details>
  108. <summary>What about drivers?</summary>
  109. To pre-empt a response I expect to this article: there's the annoying question
  110. of driver support, of course. This was an annoying line of argumentation back
  111. when Linux had poor driver support as well, and it will be a nuisance for a
  112. hypothetical Linux-compatible Rust kernel as well. Well, the same frustrated
  113. arguments I trotted out then are still ready at hand: you choose your
  114. use-cases carefully. General-purpose comes later. Building an OS which
  115. supports virtual machines, or a datacenter deployment, or a specific mobile
  116. device whose vendor is volunteering labor for drivers, and so on, will come
  117. first. You choose the hardware that supports the software, not the other way
  118. around, or build the drivers you need.
  119. That said, a decent spread of drivers should be pretty easy to implement with
  120. the talent base you have at your disposal, so I wouldn't worry about it.
  121. </details>