Live data from Hacker News

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

github.com

51–60 of 196 posts

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

#51
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…

Wow, I really like the implementation of that syscall. I've got my own toy OS project in C, for the M68k, and my `read` is "a little" less clean [0, 1].

[0]: https://gitlab.com/0xTJ/mosys/-/blob/master/src/vfs.c#L469

[1]: https://gitlab.com/0xTJ/mosys/-/blob/master/src/vfs.c#L907

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

#52
post #13
post #10

Earlier quoted context omitted.

Absolute codswallop. Linux will be here for many, many years to come yet.

Absolutely! But in Rust . Why do you think the Linux developers are bolting on Rust in the Linux kernel themselves? [0] It has already been admitted. [0] https://lore.kernel.org/lkml/20210704202756.29107-1-ojeda@ke...

It'll take decades for Linux to have everything re-written in Rust. Even then it'll take even longer for every machine to run RLinux.

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

#53

For each piece of software, there just be a version in Rust, and that version must advertise it's rustiness

For each rust submission, there shall be a comment at top lamenting the gradual rusting of hackernews.

Not lamenting in this case, the project is awesome and rust is made for this. I just find amusing that almost all popular rust projects I see have "in Rust" front and center

Must be an awesome language to work on.

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

#54

Earlier quoted context omitted.

The Rust for Linux kernel project aims to enable writing Linux kernel device drivers in Rust. See: https://lwn.net/Articles/862018/ The issue of Rust's LLVM based compiler toolchain not targeting all CPU archs is intended to be solved by the gcc-rs project. See: https://lwn.net/Articles/871283/ I think the approach the Rust for Linux project is taking is wise: Not about outright re-writes but more about focusing on t…

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?

Out of the box Rust doesn't provide any way to allocate heap memory, so, you can't run out if it.

Your ordinary userspace apps use std (the standard library) which relies on the alloc crate, and that provides heap allocation which indeed panics if the allocation fails. Because it correctly guesses that your "clever" strategy to handle allocation failure actually isn't and will just triple fault anyway so it should cut to the chase.

The kernel obviously doesn't have std, and Rust for Linux implements its own alloc crate.

Linus' requirement that you can fail memory allocation just means all the calls in alloc that can actually allocate memory now return Result to indicate whether the allocation was successful. This isn't how you'd do things in userspace, but, this isn't userspace so fine.

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

#55

For each piece of software, there just be a version in Rust, and that version must advertise it's rustiness

Now ask yourself why. Mozilla decided to create Rust after years of using C/C++. Why? Because they spent a fortune fixing the same problems over and over again, and they realized that no matter how clever their developers were, those problems were always going to arise as long as they kept using C/C++. Not because C/C++ is inherently bad, but because is more flexible than strictly needed in some ways. Rust was design…

I'm ok with things rewritten in Rust, really looks awesome as a language. And the fact every rust project advertises rust front and center compounds that image.

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

#56
post #47
post #21

This may be a naive question, but I cannot help but wonder: As C and Rust aim to be link-compatible, wouldn't it be easier to gradually replace parts of the Linux kernel with Rust code? The only technical problem I can think of is that Rust may not be available for all CPU architectures Linux supports, but this is just speculation on my part having done no research on the matter.

A practical problem is that in order to gain the benefit of linking Rust and C code, one has to give up Rust's wonderful guarantees at the interface. So until islands of Rust meet up, these interact through a C ABI, and have to expose C-like behavior.

But you still get those guarantees and benefits in the Rust implementation itself, even if not at the interface (to non-Rust code). By a similar argument, a standalone Rust program "gives up" its guarantees whenever the process makes a call to libc or to the operating system (syscalls), but this isn't really a practical problem.

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

#57
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…

Even "rewriting Linux in Rust" is far from a waste if you make it run and if your code quality is good enough for others to join.

If only you could write an entirely new (meant to be better, for some cases at least) kernel compatible with Linux hardware drivers - this would be not waste at all but in fact fantastic.

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

#58
post #44
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 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…

Any rust project like this inevitably gets sardonic replies about rewrite-in-rust fanaticism.

I agree they shouldn't have to justify themselves, but it is handy to preempt that.

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

#59
post #44
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 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…

Thanks! I'll keep doing Just for Fun :D

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

#60
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 front, both of which are severely lacking in the Unix model.

Post reply on HN