From: Boqun Feng <boqun.feng@gmail.com>
To: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
rcu@vger.kernel.org
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Will Deacon" <will@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Paul E. McKenney" <paulmck@kernel.org>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Neeraj Upadhyay" <neeraj.upadhyay@kernel.org>,
"Joel Fernandes" <joelagnelf@nvidia.com>,
"Josh Triplett" <josh@joshtriplett.org>,
"Uladzislau Rezki" <urezki@gmail.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
"Lai Jiangshan" <jiangshanlai@gmail.com>,
Zqiang <qiang.zhang@linux.dev>,
"FUJITA Tomonori" <fujita.tomonori@gmail.com>
Subject: [PATCH 1/5] rust: helpers: Generify the definitions of rust_helper_*_{read,set}*
Date: Sat, 17 Jan 2026 20:22:39 +0800 [thread overview]
Message-ID: <20260117122243.24404-2-boqun.feng@gmail.com> (raw)
In-Reply-To: <20260117122243.24404-1-boqun.feng@gmail.com>
To support atomic pointers, more {read,set} helpers will be introduced,
hence define macros to generate these helpers to ease the introduction
of the future helpers.
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
rust/helpers/atomic_ext.c | 53 +++++++++++++++++----------------------
1 file changed, 23 insertions(+), 30 deletions(-)
diff --git a/rust/helpers/atomic_ext.c b/rust/helpers/atomic_ext.c
index 7d0c2bd340da..f471c1ff123d 100644
--- a/rust/helpers/atomic_ext.c
+++ b/rust/helpers/atomic_ext.c
@@ -4,45 +4,38 @@
#include <asm/rwonce.h>
#include <linux/atomic.h>
-__rust_helper s8 rust_helper_atomic_i8_read(s8 *ptr)
-{
- return READ_ONCE(*ptr);
-}
-
-__rust_helper s8 rust_helper_atomic_i8_read_acquire(s8 *ptr)
-{
- return smp_load_acquire(ptr);
-}
-
-__rust_helper s16 rust_helper_atomic_i16_read(s16 *ptr)
-{
- return READ_ONCE(*ptr);
+#define GEN_READ_HELPER(tname, type) \
+__rust_helper type rust_helper_atomic_##tname##_read(type *ptr) \
+{ \
+ return READ_ONCE(*ptr); \
}
-__rust_helper s16 rust_helper_atomic_i16_read_acquire(s16 *ptr)
-{
- return smp_load_acquire(ptr);
+#define GEN_SET_HELPER(tname, type) \
+__rust_helper void rust_helper_atomic_##tname##_set(type *ptr, type val) \
+{ \
+ WRITE_ONCE(*ptr, val); \
}
-__rust_helper void rust_helper_atomic_i8_set(s8 *ptr, s8 val)
-{
- WRITE_ONCE(*ptr, val);
+#define GEN_READ_ACQUIRE_HELPER(tname, type) \
+__rust_helper type rust_helper_atomic_##tname##_read_acquire(type *ptr) \
+{ \
+ return smp_load_acquire(ptr); \
}
-__rust_helper void rust_helper_atomic_i8_set_release(s8 *ptr, s8 val)
-{
- smp_store_release(ptr, val);
+#define GEN_SET_RELEASE_HELPER(tname, type) \
+__rust_helper void rust_helper_atomic_##tname##_set_release(type *ptr, type val)\
+{ \
+ smp_store_release(ptr, val); \
}
-__rust_helper void rust_helper_atomic_i16_set(s16 *ptr, s16 val)
-{
- WRITE_ONCE(*ptr, val);
-}
+#define GEN_READ_SET_HELPERS(tname, type) \
+ GEN_READ_HELPER(tname, type) \
+ GEN_SET_HELPER(tname, type) \
+ GEN_READ_ACQUIRE_HELPER(tname, type) \
+ GEN_SET_RELEASE_HELPER(tname, type) \
-__rust_helper void rust_helper_atomic_i16_set_release(s16 *ptr, s16 val)
-{
- smp_store_release(ptr, val);
-}
+GEN_READ_SET_HELPERS(i8, s8)
+GEN_READ_SET_HELPERS(i16, s16)
/*
* xchg helpers depend on ARCH_SUPPORTS_ATOMIC_RMW and on the
--
2.51.0
next prev parent reply other threads:[~2026-01-17 12:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-17 12:22 [PATCH 0/5] rust: sync: Atomic pointer and RCU Boqun Feng
2026-01-17 12:22 ` Boqun Feng [this message]
2026-01-17 12:22 ` [PATCH 2/5] rust: helpers: Generify the definitions of rust_helper_*_xchg* Boqun Feng
2026-01-17 12:22 ` [PATCH 3/5] rust: helpers: Generify the definitions of rust_helper_*_cmpxchg* Boqun Feng
2026-01-17 12:22 ` [PATCH 4/5] rust: sync: atomic: Add Atomic<*mut T> support Boqun Feng
2026-01-17 17:03 ` Gary Guo
2026-01-18 4:19 ` Boqun Feng
2026-01-18 15:39 ` Gary Guo
2026-01-20 11:57 ` Boqun Feng
2026-01-20 12:37 ` Alice Ryhl
2026-01-20 14:07 ` Boqun Feng
2026-01-18 8:38 ` Dirk Behme
2026-01-18 14:57 ` Boqun Feng
2026-01-18 15:05 ` Boqun Feng
2026-01-18 19:59 ` Benno Lossin
2026-01-19 0:57 ` Boqun Feng
2026-01-19 3:09 ` FUJITA Tomonori
2026-01-17 12:22 ` [PATCH 5/5] rust: sync: rcu: Add RCU protected pointer Boqun Feng
2026-01-18 8:28 ` Dirk Behme
2026-01-19 1:03 ` Boqun Feng
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=20260117122243.24404-2-boqun.feng@gmail.com \
--to=boqun.feng@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=dakr@kernel.org \
--cc=frederic@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=jiangshanlai@gmail.com \
--cc=joelagnelf@nvidia.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=neeraj.upadhyay@kernel.org \
--cc=ojeda@kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=qiang.zhang@linux.dev \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=urezki@gmail.com \
--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