[$] Safe self-referential data structures in kernel Rust (lwn.net)
<p>
Self-referential structures that can be used without unsafe code
have posed a problem for Rust for years.
There are many cases where a self-referential data structure is the elegant
algorithmic choice, but implementing it in accordance with Rust's lifetime rules
is all but impossible. At Kangrejos 2026, Gary Guo presented a clever solution
to the problem in the context of the kernel's
<a href="https://rust.docs.kernel.org/pin_init/index.html">
pin_init crate</a>, which helps with the creation of immovable data structures,
typically for interoperability with C. Guo's changes could help remove most of
the unsafe code related to lifetimes in the
<a href="https://rust-for-linux.com/nova-gpu-driver">
Nova driver</a> and, eventually, other Rust components.
</p>
Self-referential structures that can be used without unsafe code
have posed a problem for Rust for years.
There are many cases where a self-referential data structure is the elegant
algorithmic choice, but implementing it in accordance with Rust's lifetime rules
is all but impossible. At Kangrejos 2026, Gary Guo presented a clever solution
to the problem in the context of the kernel's
<a href="https://rust.docs.kernel.org/pin_init/index.html">
pin_init crate</a>, which helps with the creation of immovable data structures,
typically for interoperability with C. Guo's changes could help remove most of
the unsafe code related to lifetimes in the
<a href="https://rust-for-linux.com/nova-gpu-driver">
Nova driver</a> and, eventually, other Rust components.
</p>
Comments