From: Alice Ryhl <aliceryhl@google.com>
To: Boqun Feng <boqun.feng@gmail.com>, Will Deacon <will@kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
"Matt Turner" <mattst88@gmail.com>,
"Magnus Lindholm" <linmag7@gmail.com>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Miguel Ojeda" <ojeda@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Lyude Paul" <lyude@redhat.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
"John Stultz" <jstultz@google.com>,
"Stephen Boyd" <sboyd@kernel.org>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>,
"Jan Kara" <jack@suse.cz>,
linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
rust-for-linux@vger.kernel.org, linux-fsdevel@vger.kernel.org,
"Alice Ryhl" <aliceryhl@google.com>
Subject: [PATCH 1/5] arch: add CONFIG_ARCH_USE_CUSTOM_READ_ONCE for arm64/alpha
Date: Wed, 31 Dec 2025 12:22:25 +0000 [thread overview]
Message-ID: <20251231-rwonce-v1-1-702a10b85278@google.com> (raw)
In-Reply-To: <20251231-rwonce-v1-0-702a10b85278@google.com>
By exposing this variable as a config option, conditional compilation in
Rust code may rely on it to determine whether it should use a volatile
read or call a C helper function to perform a READ_ONCE operation.
This config option is also added on alpha for consistency, even if Rust
does not support alpha right now.
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
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 ++--
5 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/arch/Kconfig b/arch/Kconfig
index 31220f512b16d5cfbc259935c2d3675b60c1e25c..683176bb09e50e31f398bb92678283e5de66b282 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -229,6 +229,17 @@ config HAVE_EFFICIENT_UNALIGNED_ACCESS
See Documentation/core-api/unaligned-memory-access.rst for more
information on the topic of unaligned memory accesses.
+config ARCH_USE_CUSTOM_READ_ONCE
+ bool
+ help
+ Some architectures reorder address-dependent volatile loads,
+ which means that the default implementation of READ_ONCE that
+ relies on a volatile load is not appropriate.
+
+ This symbol should be selected by an architecture if it
+ redefines READ_ONCE to use a different implementation than a
+ volatile load.
+
config ARCH_USE_BUILTIN_BSWAP
bool
help
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 80367f2cf821ceb4fc29485b7b21b37d5c310765..1d5d48153ba0087554221e9412a6af0c672d3f5c 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -11,6 +11,7 @@ config ALPHA
select ARCH_NO_PREEMPT
select ARCH_NO_SG_CHAIN
select ARCH_USE_CMPXCHG_LOCKREF
+ select ARCH_USE_CUSTOM_READ_ONCE if SMP
select FORCE_PCI
select PCI_DOMAINS if PCI
select PCI_SYSCALL if PCI
diff --git a/arch/alpha/include/asm/rwonce.h b/arch/alpha/include/asm/rwonce.h
index 35542bcf92b3a883df353784bcb2d243475ccd91..c9f21aa0764625b24e8957923926d09a2eb97e7c 100644
--- a/arch/alpha/include/asm/rwonce.h
+++ b/arch/alpha/include/asm/rwonce.h
@@ -5,7 +5,7 @@
#ifndef __ASM_RWONCE_H
#define __ASM_RWONCE_H
-#ifdef CONFIG_SMP
+#ifdef CONFIG_ARCH_USE_CUSTOM_READ_ONCE
#include <asm/barrier.h>
@@ -28,7 +28,7 @@
(typeof(x))__x; \
})
-#endif /* CONFIG_SMP */
+#endif /* CONFIG_ARCH_USE_CUSTOM_READ_ONCE */
#include <asm-generic/rwonce.h>
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 93173f0a09c7deb07b46ab4f16a1a0e4320dfbf1..cd16053c8302479458a05c23ba9cfb73ee50232c 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -89,6 +89,7 @@ config ARM64
select ARCH_KEEP_MEMBLOCK
select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE
select ARCH_USE_CMPXCHG_LOCKREF
+ select ARCH_USE_CUSTOM_READ_ONCE if LTO
select ARCH_USE_GNU_PROPERTY
select ARCH_USE_MEMTEST
select ARCH_USE_QUEUED_RWLOCKS
diff --git a/arch/arm64/include/asm/rwonce.h b/arch/arm64/include/asm/rwonce.h
index 78beceec10cda47b319db29d9f79d2a5df35e92d..5da6b2d6a12399a520f7a3310014de723baa278a 100644
--- a/arch/arm64/include/asm/rwonce.h
+++ b/arch/arm64/include/asm/rwonce.h
@@ -5,7 +5,7 @@
#ifndef __ASM_RWONCE_H
#define __ASM_RWONCE_H
-#if defined(CONFIG_LTO) && !defined(__ASSEMBLER__)
+#if defined(CONFIG_ARCH_USE_CUSTOM_READ_ONCE) && !defined(__ASSEMBLER__)
#include <linux/compiler_types.h>
#include <asm/alternative-macros.h>
@@ -62,7 +62,7 @@
})
#endif /* !BUILD_VDSO */
-#endif /* CONFIG_LTO && !__ASSEMBLER__ */
+#endif /* CONFIG_ARCH_USE_CUSTOM_READ_ONCE && !__ASSEMBLER__ */
#include <asm-generic/rwonce.h>
--
2.52.0.351.gbe84eed79e-goog
next prev parent reply other threads:[~2025-12-31 12:22 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-31 12:22 [PATCH 0/5] Add READ_ONCE and WRITE_ONCE to Rust Alice Ryhl
2025-12-31 12:22 ` Alice Ryhl [this message]
2025-12-31 12:22 ` [PATCH 2/5] rust: sync: add READ_ONCE and WRITE_ONCE Alice Ryhl
2026-01-06 12:29 ` Andreas Hindborg
2026-01-06 12:53 ` Boqun Feng
2025-12-31 12:22 ` [PATCH 3/5] rust: sync: support using bool with READ_ONCE Alice Ryhl
2025-12-31 15:25 ` Gary Guo
2026-01-06 12:43 ` Peter Zijlstra
2026-01-06 12:51 ` Alice Ryhl
2026-01-06 18:12 ` Gary Guo
2026-01-07 8:33 ` Peter Zijlstra
2026-01-07 18:12 ` Gary Guo
2025-12-31 12:22 ` [PATCH 4/5] rust: hrtimer: use READ_ONCE instead of read_volatile Alice Ryhl
2026-01-01 2:11 ` FUJITA Tomonori
2026-01-01 4:00 ` FUJITA Tomonori
2026-01-06 12:37 ` Andreas Hindborg
2026-01-06 13:28 ` FUJITA Tomonori
2026-01-07 10:11 ` Andreas Hindborg
2026-01-07 11:22 ` FUJITA Tomonori
2026-01-07 18:21 ` Andreas Hindborg
2026-01-09 2:10 ` FUJITA Tomonori
2026-01-09 10:42 ` Andreas Hindborg
2026-01-07 11:51 ` Boqun Feng
2026-01-07 12:48 ` Andreas Hindborg
2026-01-06 15:23 ` Gary Guo
2026-01-06 18:43 ` Alice Ryhl
2026-01-07 0:47 ` John Hubbard
2026-01-07 1:08 ` Boqun Feng
2026-01-07 2:59 ` John Hubbard
2026-01-07 1:18 ` Boqun Feng
2025-12-31 12:22 ` [PATCH 5/5] rust: fs: " Alice Ryhl
2026-01-21 0:47 ` Boqun Feng
2025-12-31 15:12 ` [PATCH 0/5] Add READ_ONCE and WRITE_ONCE to Rust Gary Guo
2026-01-01 0:53 ` Alice Ryhl
2026-01-01 1:13 ` Boqun Feng
2026-01-06 12:41 ` Andreas Hindborg
2026-01-06 13:09 ` Boqun Feng
2026-01-06 14:56 ` Peter Zijlstra
2026-01-06 18:18 ` Paul E. McKenney
2026-01-06 19:28 ` Marco Elver
2026-01-09 2:09 ` Paul E. McKenney
2026-01-09 12:00 ` Marco Elver
2026-01-07 8:43 ` Peter Zijlstra
2026-01-07 19:17 ` Paul E. McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251231-rwonce-v1-1-702a10b85278@google.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@kernel.org \
--cc=anna-maria@linutronix.de \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=brauner@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=dakr@kernel.org \
--cc=frederic@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=jack@suse.cz \
--cc=jstultz@google.com \
--cc=linmag7@gmail.com \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=mark.rutland@arm.com \
--cc=mattst88@gmail.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=richard.henderson@linaro.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
--cc=tmgross@umich.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®