Live data from Hacker News

Kerla: Monolithic kernel in Rust, aiming for Linux ABI compatibility

github.com

111–120 of 196 posts

Re: Kerla: Monolithic kernel in Rust, aiming for Linux ABI compatibility

#111

Earlier quoted context omitted.

Last I checked, one of the big problems was the Rust panics when you run out of memory, which is unacceptable in the kernel. Is there any progress on that?

>> one of the big problems was the Rust panics when you run out of memory, which is unacceptable in the kernel. If the kernel is running out of memory, IMHO that's a bug. The kernel is ultimately responsible for memory management right? It needs to prioritize itself over everything else or the system is in trouble.

This sounds like a design choice that was made decades ago and permeated everything else in Linux. I don't think it's changeable at this point, if they wanted to.

Re: Kerla: Monolithic kernel in Rust, aiming for Linux ABI compatibility

#112

Rewriting the Linux kernel in rust would be a rehash of why we ended up with Linux in the first place: rewriting an older OS from scratch. I would love to see a solid implementation of a real micro kernel based OS based on a message passing core in Rust to become a viable alternative to the now 50 year old Unix architecture. This would give us a possibility of some real progress on the security and process scheduling…

Fuchsia and QNX provide a lot of what you want.

https://en.wikipedia.org/wiki/QNX

https://en.wikipedia.org/wiki/Fuchsia_(operating_system)

https://lobste.rs/s/p8bizb/getting_know_fuchsia_google_s_ope...

Re: Kerla: Monolithic kernel in Rust, aiming for Linux ABI compatibility

#113
post #41

Author here. I'm surprised to see my hobby project on Hacker News. I know this kind of stuff spark the ``it's meaningless to rewrite everything (especially Linux) in Rust'' debate. I agree 100% that rewriting Linux in Rust (or your favorite language) is just a waste of time and such a project won't live long. That said, what I'd say here is that it's fun. Really fun. Implementing ABI compatibility requires you to und…

Aside from "rewrite in rust" debate that I was unaware of, there seems to be this pervasive attitude among the HN hivemind that the end-goal for all projects, side- or main-, is "launch", and therefore needs a market analysis to decide the "worth" of such an idea, and it ends up being rather silly. For example, I've written a Mandelbrot visualizer so many times I've lost count. Not because the world needs another poo…

I have a A* search algorithm and a toy compiler that I use exactly for the same purpose.

I just rewrite them all the time as means to get a feeling about programming languages.

I dumped a couple of other stuff on GitHub so that HR people are happy to get a link that they never read anyway.

Then I get back to Java and .NET at the office. :)

Re: Kerla: Monolithic kernel in Rust, aiming for Linux ABI compatibility

#114
post #41

Author here. I'm surprised to see my hobby project on Hacker News. I know this kind of stuff spark the ``it's meaningless to rewrite everything (especially Linux) in Rust'' debate. I agree 100% that rewriting Linux in Rust (or your favorite language) is just a waste of time and such a project won't live long. That said, what I'd say here is that it's fun. Really fun. Implementing ABI compatibility requires you to und…

I'm new to Rust and am far less along than you are, as evidenced by this project. I noticed that in the few files I spot checked, there aren't many/any tests. Without any context or opinion, I'm curious whether unit and integration testing are hard for a project like this.

Re: Kerla: Monolithic kernel in Rust, aiming for Linux ABI compatibility

#115
post #67

Earlier quoted context omitted.

Google has decided to go forward anyway. Just like Android Linux compiles just fine with clang for the last five years or so, it now makes use of Rust. https://source.android.com/setup/build/rust/building-rust-mo... If upstream ever cares to support clang or Rust, that is another matter.

Unless I'm missing something, that link refers to building Android user-mode components in Rust, not kernel components in Rust.

That's correct, but it came after them rebuilding the bluetooth stack https://news.ycombinator.com/item?id=26647981

Re: Kerla: Monolithic kernel in Rust, aiming for Linux ABI compatibility

#116
post #113

Earlier quoted context omitted.

Aside from "rewrite in rust" debate that I was unaware of, there seems to be this pervasive attitude among the HN hivemind that the end-goal for all projects, side- or main-, is "launch", and therefore needs a market analysis to decide the "worth" of such an idea, and it ends up being rather silly. For example, I've written a Mandelbrot visualizer so many times I've lost count. Not because the world needs another poo…

I have a A* search algorithm and a toy compiler that I use exactly for the same purpose. I just rewrite them all the time as means to get a feeling about programming languages. I dumped a couple of other stuff on GitHub so that HR people are happy to get a link that they never read anyway. Then I get back to Java and .NET at the office. :)

I've actually been considering adding a toy compiler to my collection of getting-up-to-speed projects, do you mind sharing what you think are good features?

Re: Kerla: Monolithic kernel in Rust, aiming for Linux ABI compatibility

#117

Rewriting the Linux kernel in rust would be a rehash of why we ended up with Linux in the first place: rewriting an older OS from scratch. I would love to see a solid implementation of a real micro kernel based OS based on a message passing core in Rust to become a viable alternative to the now 50 year old Unix architecture. This would give us a possibility of some real progress on the security and process scheduling…

Why do people implicitly assume that micro kernels are the best OS design?

In fact, micro kernels have a lot of issues and limit the possibilities of what an OS can do! One of the most important issues is they prevents resource sharing in a rich and efficient way between the components of the kernel. They make building rich relationships between kernel data structures and kernel subsystems very messy, complicated, impracticable and very inefficient.

Micro kernels are delusional and people should stop implicitly assuming their superiority.

Re: Kerla: Monolithic kernel in Rust, aiming for Linux ABI compatibility

#118
post #89
post #44

Earlier quoted context omitted.

> I know this kind of stuff spark the ``it's meaningless to rewrite everything (especially Linux) in Rust'' debate. I agree 100% that rewriting Linux in Rust (or your favorite language) is just a waste of time and such a project won't live long. Considering that this is exactly how Linux was born (just a hobby project for fun), I wouldn't assume so fast that it's useless. Moreover, you don't need to justify yourself…

I don't see why we need to pretend that every hobby has the potential for greatness. Being a hobby is a good enough end to itself. In fact in this instance I think it's a little disingenuous to quote Linux and say it could happen again. The industry is totally different now. There's much more competition than there was when Linux was released and that competition is much more mature too. Plus the bar for a production…

> In fact in this instance I think it's a little disingenuous to quote Linux and say it could happen again.

Seems apropos to me, given the fact that a Linux ABI compatible hobby project is under discussion - and that everyone here is familiar with the famous Usenet announcement.

> The industry is totally different now. There's much more competition than there was when...

I wonder how you define "competition"? Because there were way more operating systems in use then, and the industry was far more fractured. Fractured in a way that was meaningful - not like today where you can spin up a VM and be productive in short order, thanks to the significant lack of distinguishing difference. That is the really interesting thing about these hobby projects - they introduce possibilities that are either completely ignored by organizations suffering from inertia constraints, or can't be mimicked because they're diametrically opposed to present designs.

Re: Kerla: Monolithic kernel in Rust, aiming for Linux ABI compatibility

#119
post #117

Rewriting the Linux kernel in rust would be a rehash of why we ended up with Linux in the first place: rewriting an older OS from scratch. I would love to see a solid implementation of a real micro kernel based OS based on a message passing core in Rust to become a viable alternative to the now 50 year old Unix architecture. This would give us a possibility of some real progress on the security and process scheduling…

Why do people implicitly assume that micro kernels are the best OS design? In fact, micro kernels have a lot of issues and limit the possibilities of what an OS can do! One of the most important issues is they prevents resource sharing in a rich and efficient way between the components of the kernel. They make building rich relationships between kernel data structures and kernel subsystems very messy, complicated, im…

Message passing at first seems interesting and neat and useful. It is for some cases. But it comes at a cost of complexity and latency.

Re: Kerla: Monolithic kernel in Rust, aiming for Linux ABI compatibility

#120

Earlier quoted context omitted.

It has nothing to do with Result, whatsoever. Result does not allocate. If you used a Result that way, you could certainly try to "gracefully" handle the allocation failure, but if you think it would be easy, you would be wrong. As Tialaramex said, you are probably just going to make the problem worse because it is very difficult to ensure you do not attempt to allocate during allocation-failure-recovery. Rustc doesn…

An addendum to tie this back to the original discussion: the reason kernel devs want these APIs more than userland is that (a) in a kernel, panicking = crashing the computer, which would be bad, and (b) they have a much bigger toolbox for handling OOM. They can kill entire misbehaving processes. What are you going to do in your little program, clear a cache whose objects are sprinkled evenly across 150 different page…

> panicking = crashing the computer

That isn't very accurate. In Rust when programming in no_std, you can (must?) define your own panic handler:

https://doc.rust-lang.org/nomicon/panic-handler.html

Which you would define in the kernel. While I'm not going to speculate on exactly what the implementation would look like, you definitely do not need to "crash" the computer. I haven't done any kernel programming, but I'm guessing the kernel could do some things at that point with shared memory space that is already allocated to deal with this situation and try to recover in some way.

Edit: for example, I just found this in the kerla project: https://github.com/nuta/kerla/blob/88fd40823852a63bd639e602b...

That halts now, but it probably doesn't need to, or could do it conditionally based on the contents of PanicInfo.

Post reply on HN