From: FUJITA Tomonori <fujita.tomonori@gmail.com>
To: boqun.feng@gmail.com, ojeda@kernel.org, peterz@infradead.org,
will@kernel.org
Cc: acourbot@nvidia.com, a.hindborg@kernel.org, aliceryhl@google.com,
bjorn3_gh@protonmail.com, dakr@kernel.org, gary@garyguo.net,
lossin@kernel.org, mark.rutland@arm.com, tmgross@umich.edu,
rust-for-linux@vger.kernel.org
Subject: [PATCH v3 1/4] rust: sync: Add i8/i16 atomic_load_acquire/atomic_store_release helpers
Date: Thu, 11 Dec 2025 20:38:23 +0900 [thread overview]
Message-ID: <20251211113826.1299077-2-fujita.tomonori@gmail.com> (raw)
In-Reply-To: <20251211113826.1299077-1-fujita.tomonori@gmail.com>
Add helper functions to expose smp_load_acquire() and
smp_store_release() for i8 and i16 types.
The smp_load_acquire() and smp_store_release() macros require type
information (sizeof) to generate appropriate architecture-specific
memory ordering instructions. Therefore, separate helper functions are
needed for each type size.
These helpers expose different symbol names than their C counterparts
so they are split into atomic_ext.c instead of atomic.c. The symbol
names; atomic_[i8|i16]_load_acquire and atomic_[i8|i16]_store_release
makes the interface Rust/C clear, consistent with i32/i64.
These helpers will be used by the upcoming Atomic<i8> and Atomic<i16>
implementation to provide proper Acquire/Release semantics across all
architectures.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
---
rust/helpers/atomic_ext.c | 23 +++++++++++++++++++++++
rust/helpers/helpers.c | 1 +
2 files changed, 24 insertions(+)
create mode 100644 rust/helpers/atomic_ext.c
diff --git a/rust/helpers/atomic_ext.c b/rust/helpers/atomic_ext.c
new file mode 100644
index 000000000000..a10c723ab224
--- /dev/null
+++ b/rust/helpers/atomic_ext.c
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <asm/barrier.h>
+
+__rust_helper s8 rust_helper_atomic_i8_load_acquire(s8 *ptr)
+{
+ return smp_load_acquire(ptr);
+}
+
+__rust_helper s16 rust_helper_atomic_i16_load_acquire(s16 *ptr)
+{
+ return smp_load_acquire(ptr);
+}
+
+__rust_helper void rust_helper_atomic_i8_store_release(s8 *ptr, s8 val)
+{
+ smp_store_release(ptr, val);
+}
+
+__rust_helper void rust_helper_atomic_i16_store_release(s16 *ptr, s16 val)
+{
+ smp_store_release(ptr, val);
+}
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index 79c72762ad9c..15d75578f459 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -8,6 +8,7 @@
*/
#include "atomic.c"
+#include "atomic_ext.c"
#include "auxiliary.c"
#include "barrier.c"
#include "binder.c"
--
2.43.0
next prev parent reply other threads:[~2025-12-11 11:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 11:38 [PATCH v3 0/4] rust: Add i8 and i16 atomic support FUJITA Tomonori
2025-12-11 11:38 ` FUJITA Tomonori [this message]
2025-12-11 11:38 ` [PATCH v3 2/4] rust: helpers: Add i8/i16 relaxed atomic helpers FUJITA Tomonori
2025-12-11 11:38 ` [PATCH v3 3/4] rust: sync: atomic: Add i8/i16 load and store support FUJITA Tomonori
2025-12-11 11:38 ` [PATCH v3 4/4] rust: sync: atomic: Add store_release/load_acquire tests FUJITA Tomonori
2025-12-11 16:49 ` [PATCH v3 0/4] rust: Add i8 and i16 atomic support Joel Fernandes
2025-12-11 17:37 ` Gary Guo
2025-12-11 20:05 ` Joel Fernandes
2025-12-14 21:54 ` 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=20251211113826.1299077-2-fujita.tomonori@gmail.com \
--to=fujita.tomonori@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=lossin@kernel.org \
--cc=mark.rutland@arm.com \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--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;
as well as URLs for NNTP newsgroup(s).