Rust for Linux Workshop: The perils of pinning
lwn.net
lwn.net
In C any problems caused by this are "solved" just by telling programmers not to do that. In Rust that's not good enough — safety guarantees are supposed to catch such violations, so the goal is to automatically and robustly prevent incorrect struct moves. Rust already makes that safe by default when using the borrow checker, but it doesn't have a nice built-in mechanism for preventing moves of non-borrowed structs.
struct list_head {
struct list_head *next, *prev;
};
I'd done a few Rust tutorials before I thought to myself Hmmm, what's something basic I can try making in Rust? I know, a linked list. Oh boy, was that a schooling...1. Does Rust have an idiomatic way of providing a similar data structure that also limits allocations and maintains cache-friendliness?
2. How pervasive are these intrusive linked lists in the kernel code, especially in boundaries between major systems? Would it be possible to create seams in the kernel code that pass structures with idiomatic Rust equivalents, then use those as a guide to moving Rust into the kernel without contorting it to work with C data structures that are hard to represent?