All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Challenges of Implementing Linux Kernel's READ_ONCE() and WRITE_ONCE() Macros in Rust

By

todsacerdoti

4mo ago· 6 min readenInsight

Summary

The article discusses the challenges of implementing READ_ONCE() and WRITE_ONCE() macros from the Linux kernel in Rust code. These macros are essential for lockless algorithms and device-memory access in the kernel, with nearly 8,000 call sites for READ_ONCE(). The article explores why these C-language macros don't translate directly to Rust, examining technical limitations, language differences, and potential workarounds for Rust's integration into the Linux kernel.

Key quotes

· 3 pulled
The READ_ONCE() and WRITE_ONCE() macros are heavily used within the kernel; there are nearly 8,000 call sites for READ_ONCE().
They are key to the implementation of many lockless algorithms and can be necessary for some types of device-memory access.
So one might think that, as the amount of Rust code in the kernel increases, there would be a need for Rust equivalents of these macros.
Snippet from the RSS feed
The READ_ONCE() and WRITE_ONCE() macros are heavily used within the kernel; there are nearly 8, [...]

You might also wanna read

Restartable Sequences: A Linux Kernel Feature for Lock-Free Thread-Safe Programming

This article explores restartable sequences (rseq), a Linux kernel feature introduced in version 4.18 (circa 2018) that enables creation of

justine.lol·10h ago

Linux Kernel /proc/*/mem Pseudofile: Understanding Punch Through Semantics for Unwritable Memory

This article explores the Linux kernel's /proc/*/mem pseudofile and its unique 'punch through' semantics that allow writes to succeed even w

offlinemark.com·2mo ago

Linux Kernel Development: Introducing the Swap Table for Modernized Memory Management

The article discusses a new Linux kernel feature called the 'swap table' that aims to modernize the swap subsystem. The swap subsystem is de

lwn.net·3mo ago

Zig Days: Collaborative Full-Day Programming Events for the Zig Community

Zig Days are full-day collaborative programming events organized by the Zig community, typically held on Saturdays. Participants meet in the

kristoff.it·3d ago

Spectre Programming Language Documentation: A Contract-Based Approach to Safe Low-Level Systems Programming

Spectre is a contract-based programming language designed for safe low-level systems programming. It enforces correctness through type-level

spectre-docs.pages.dev·16d ago

Linux kernel patch proposes per-function "killswitch" for runtime short-circuit mitigation

A Linux kernel patch proposal by Sasha Levin introduces a "killswitch" mechanism — a per-function short-circuit mitigation primitive designe

lwn.net·22d ago