13 ms·
Mostly GPU drivers
by dxroshan 9mo ago
Mostly GPU drivers
- ramon156 9mo agoRightfully so, its probably the place where you'll het most ROI
- weebull 9mo agoI don't understand why. Working with hardware you're going to have to do various things with `unsafe`. Interfacing to C (the rest of the kernel) you'll have to be using `unsafe`. In my mind, the reasoning for rust in this situation seems flawed.
- encom 9mo ago[flagged]
- timeon 9mo agoWhat was the question? I saw only one assumption.
- phyzome 9mo agoThe point is that lots of the code won't be `unsafe`, and therefore you benefit from memory safety in those parts.
- maccard 9mo agoI’ve done a decent amount of low level code - (never written a driver but I’m still young). The vast majority of it can be safe, and call into unsafe wrapped when needed. My experience is that a very very small amount of stuff actually needs unsafe and the only reason the unsafe C code is used is because it’s possible not because it’s necessary.
- jacquesm 9mo agoIt is interesting how many very experienced programmers have not yet learned your lesson, so you may be young but you are doing very well indeed. Kudos.
- viraptor 9mo agoThe amount of unsafe is pretty small and limited to where the interfacing with io or relevant stuff is actually happening. For example (random selection) https://lkml.org/lkml/2023/3/7/764 https://lkml.org/lkml/2023/3/7/764 has a few unsafes, but either: a) trivial structure access, or b) documented regarding why it's valid. The rest of the code still benefits. But that's not the only reason Rust is useful - see the end of the write-up from the module author https://asahilinux.org/2022/11/tales-of-the-m1-gpu/ https://asahilinux.org/2022/11/tales-of-the-m1-gpu/ ("Rust is magical!" section)
- School-Cotton 9mo agoWhy does that matter? Rust with some "unsafe" is still much nicer to use than C. In fact one of the main points of Rust is the ability to build safe abstractions on top of unsafe code, rather than every line in the entire program always being unsafe and possibly invoking UB.
- maximilianburke 9mo agoUnsafe in Rust doesn't mean anything goes. Specifically it means that you are going to 1) dereference a raw pointer; or 2) call an unsafe function/method; or 3) access/modify a mutable static variable; or 4) implement an unsafe trait; or 5) access fields of a union. You still get the safety guarantees of Rust in unsafe code like bounds checking and lifetimes.