HeadlinesBriefing favicon HeadlinesBriefing.com

Rust vs C: Kernel Concurrency Debate

Hacker News: Front Page •
×

Kernel developers rely on READ_ONCE() and WRITE_ONCE() macros to enforce single reads or writes, ensuring atomicity in lockless code. In 2024, Rust contributors pushed for Rust equivalents, but the community opted for clearer atomic primitives instead of porting the macros to maintain safety and clarity across the codebase for future.

Critics like Gary Guo and Boqun Feng argued that the macros blur intent, mixing atomicity with race prevention. They favored Atomic::from_ptr().load(Relaxed), which specifies exact guarantees. The debate highlighted how Rust’s stricter type system reshapes low‑level concurrency in the Linux kernel as developers integrate more Rust modules into the core today.

With the Rust patch series stalled, kernel maintainers will continue updating C code to use WRITE_ONCE() correctly, while Rust code adopts explicit atomic calls. This split approach may double the learning curve but promises clearer semantics. Watch for future kernel releases that reconcile the two APIs and streamline concurrency today.