Skip to content

Add READ_ONCE and WRITE_ONCE to Rust

Alice Ryhl linux-alpha linux-arm-kernel linux-fsdevel lkml rust-for-linux 1 version In review

Get series with b4
b4 am [email protected] change-id 20251230-rwonce-1e8d2ee0bcf9

Versions newest first

  1. v1 Latest5 patches 38 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5arch: add CONFIG_ARCH_USE_CUSTOM_READ_ONCE for arm64/alphaarch/Kconfig arch/alpha/Kconfig arch/alpha/include/asm/rwonce.h +2 more+17 -40 replies
2/5rust: sync: add READ_ONCE and WRITE_ONCEMAINTAINERS rust/helpers/helpers.c rust/helpers/rwonce.c +2 more+227 -02 replies
3/5rust: sync: support using bool with READ_ONCErust/kernel/sync/rwonce.rs+19 -06 replies
4/5rust: hrtimer: use READ_ONCE instead of read_volatilerust/kernel/time/hrtimer.rs+3 -517 replies
5/5rust: fs: use READ_ONCE instead of read_volatilerust/kernel/fs/file.rs+2 -61 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] Add READ_ONCE and WRITE_ONCE to Rust

There are currently a few places in the kernel where we use volatile reads when we really should be using READ_ONCE. To make it possible to replace these with proper READ_ONCE calls, introduce a Rust version of READ_ONCE.

A new config option CONFIG_ARCH_USE_CUSTOM_READ_ONCE is introduced so that Rust is able to use conditional compilation to implement READ_ONCE in terms of either a volatile read, or by calling into a C helper function, depending on the architecture.

This series is intended to be merged through ATOMIC INFRASTRUCTURE.

---
Alice Ryhl (5):
arch: add CONFIG_ARCH_USE_CUSTOM_READ_ONCE for arm64/alpha
rust: sync: add READ_ONCE and WRITE_ONCE
rust: sync: support using bool with READ_ONCE
rust: hrtimer: use READ_ONCE instead of read_volatile
rust: fs: use READ_ONCE instead of read_volatile

 MAINTAINERS                     |   2 +
 arch/Kconfig                    |  11 +++
 arch/alpha/Kconfig              |   1 +
 arch/alpha/include/asm/rwonce.h |   4 +-
 arch/arm64/Kconfig              |   1 +
 arch/arm64/include/asm/rwonce.h |   4 +-
 rust/helpers/helpers.c          |   1 +
 rust/helpers/rwonce.c           |  34 +++++++
 rust/kernel/fs/file.rs          |   8 +-
 rust/kernel/sync.rs             |   2 +
 rust/kernel/sync/rwonce.rs      | 207 ++++++++++++++++++++++++++++++++++++++++
 rust/kernel/time/hrtimer.rs     |   8 +-
 12 files changed, 268 insertions(+), 15 deletions(-)

---
base-commit: f8f9c1f4d0c7a64600e2ca312dec824a0bc2f1da
change-id: 20251230-rwonce-1e8d2ee0bcf9

Best regards,

Signature · 1 line
Alice Ryhl <[email protected]>