From: Boqun Feng <boqun.feng@gmail.com>
To: FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: ojeda@kernel.org, alex.gaynor@gmail.com, peterz@infradead.org,
will@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com,
bjorn3_gh@protonmail.com, dakr@kernel.org, gary@garyguo.net,
lossin@kernel.org, mark.rutland@arm.com,
rust-for-linux@vger.kernel.org, tmgross@umich.edu
Subject: Re: [PATCH v1 1/3] rust: sync: Add smp_store_release/smp_load_acquire helpers
Date: Fri, 14 Nov 2025 21:22:28 -0800 [thread overview]
Message-ID: <aRgOFGLqkolf4j4T@tardis.local> (raw)
In-Reply-To: <20251115050305.3872412-2-fujita.tomonori@gmail.com>
Hi Tomo,
Thanks for taking a look at this.
On Sat, Nov 15, 2025 at 02:03:03PM +0900, FUJITA Tomonori wrote:
> Add smp_store_release/smp_load_acquire helpers to support
> store_release/load_acquire for i8/i16.
>
> Both are implemented as a C macro and type information is necessary so
> the size argument is necessary unlike the C version.
>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
> ---
> rust/helpers/barrier.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/rust/helpers/barrier.c b/rust/helpers/barrier.c
Could you just define helpers:
atomic_{i8,i16}_store{,_release}(), atomic_{i8,i16}_load{,_acquire}()
in a separate helper file? (e.g. rust/helpers/atomic_ext.c).
In this way, you could just use C to implement these and that'll make
the interface Rust/C more clear.
Eventually I will the macro declare_and_impl_atomic_methods!() support
customized list of types, but right now a dedicated macro to generate
all impls for AtomicBasicOps of i8/i16 is fine.
Regards,
Boqun
> index cdf28ce8e511..b66ef792c7be 100644
> --- a/rust/helpers/barrier.c
> +++ b/rust/helpers/barrier.c
> @@ -16,3 +16,27 @@ void rust_helper_smp_rmb(void)
> {
> smp_rmb();
> }
> +
> +void rust_helper_smp_store_release(void *ptr, u64 val, size_t size)
> +{
> + switch (size) {
> + case 1:
> + smp_store_release((u8 *)ptr, (u8)val);
> + break;
> + case 2:
> + smp_store_release((u16 *)ptr, (u16)val);
> + break;
> + }
> +}
> +
> +void rust_helper_smp_load_acquire(void *ptr, void *val, size_t size)
> +{
> + switch (size) {
> + case 1:
> + *(u8 *)val = smp_load_acquire((u8 *)ptr);
> + break;
> + case 2:
> + *(u16 *)val = smp_load_acquire((u16 *)ptr);
> + break;
> + }
> +}
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-11-15 5:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-15 5:03 [PATCH v1 0/3] rust: Add i8 and i16 atomic support FUJITA Tomonori
2025-11-15 5:03 ` [PATCH v1 1/3] rust: sync: Add smp_store_release/smp_load_acquire helpers FUJITA Tomonori
2025-11-15 5:22 ` Boqun Feng [this message]
2025-11-15 6:22 ` FUJITA Tomonori
2025-11-15 7:01 ` Boqun Feng
2025-11-15 13:23 ` FUJITA Tomonori
2025-11-15 5:03 ` [PATCH v1 2/3] rust: sync: atomic: Add i8 and i16 support (load and store) FUJITA Tomonori
2025-11-15 5:03 ` [PATCH v1 3/3] rust: sync: atomic: Add store_release/load_acquire tests FUJITA Tomonori
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=aRgOFGLqkolf4j4T@tardis.local \
--to=boqun.feng@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=dakr@kernel.org \
--cc=fujita.tomonori@gmail.com \
--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).