* Re: [PATCH v1 0/4] rust: Add i8/i16 atomic xchg helpers [not found] <20251217213742.639812-1-fujita.tomonori@gmail.com> @ 2025-12-18 9:18 ` Boqun Feng 2025-12-18 11:08 ` FUJITA Tomonori 0 siblings, 1 reply; 2+ messages in thread From: Boqun Feng @ 2025-12-18 9:18 UTC (permalink / raw) To: FUJITA Tomonori Cc: ojeda, peterz, will, acourbot, a.hindborg, aliceryhl, bjorn3_gh, dakr, gary, lossin, mark.rutland, tmgross, rust-for-linux, James E.J. Bottomley, Helge Deller, linux-parisc, David S. Miller, Andreas Larsson, sparclinux, Vineet Gupta, linux-snps-arc, Brian Cain, linux-hexagon, linux-arch [Cc parisc, sparc32, arc and hexagon] On Thu, Dec 18, 2025 at 06:37:38AM +0900, FUJITA Tomonori wrote: > This adds atomic xchg helpers with full, acquire, release, and relaxed > orderings in preparation for i8/i16 atomic xchg support. > > The architectures supporting Rust, implement atomic xchg families > using architecture-specific instructions. So the helpers just call > them. > > Note that the architectures that support Rust handle xchg differently: > > - arm64 and riscv support xchg with all the orderings. > > - x86_64 and loongarch support only full-ordering xchg. They calls the > full-ordering xchg for any orderings. > > - arm v7 supports only relaxed-odering xchg. It uses __atomic_op_ > macros to add barriers properly. > Thanks for the work! And please do Cc linux-arch next time when doing architecture-related changes. We would get more experts to take a look. I think the current implementation expects that xchg() work with normal store/load, and that requires ARCH_SUPPORTS_ATOMIC_RMW. So could you add a comment saying the current implementation only support ARCH_SUPPORTS_ATOMIC_RMW architectures? And when you wire up the rust helpers, I think using #[cfg(CONFIG_ARCH_SUPPORTS_ATOMIC_RMW)] is a good idea. This will at least let the !ARCH_SUPPORTS_ATOMIC_RMW archs know that something is missing here. Regards, Boqun > FUJITA Tomonori (4): > rust: helpers: Add i8/i16 atomic xchg helpers > rust: helpers: Add i8/i16 atomic xchg_acquire helpers > rust: helpers: Add i8/i16 atomic xchg_release helpers > rust: helpers: Add i8/i16 atomic xchg_relaxed helpers > > rust/helpers/atomic_ext.c | 41 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) > > > base-commit: 02c5c8c11bbd34cdd9c566dd4ecca48995c09621 > -- > 2.43.0 > ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v1 0/4] rust: Add i8/i16 atomic xchg helpers 2025-12-18 9:18 ` [PATCH v1 0/4] rust: Add i8/i16 atomic xchg helpers Boqun Feng @ 2025-12-18 11:08 ` FUJITA Tomonori 0 siblings, 0 replies; 2+ messages in thread From: FUJITA Tomonori @ 2025-12-18 11:08 UTC (permalink / raw) To: boqun.feng Cc: fujita.tomonori, ojeda, peterz, will, acourbot, a.hindborg, aliceryhl, bjorn3_gh, dakr, gary, lossin, mark.rutland, tmgross, rust-for-linux, James.Bottomley, deller, linux-parisc, davem, andreas, sparclinux, vgupta, linux-snps-arc, bcain, linux-hexagon, linux-arch On Thu, 18 Dec 2025 18:18:17 +0900 Boqun Feng <boqun.feng@gmail.com> wrote: > [Cc parisc, sparc32, arc and hexagon] > > On Thu, Dec 18, 2025 at 06:37:38AM +0900, FUJITA Tomonori wrote: >> This adds atomic xchg helpers with full, acquire, release, and relaxed >> orderings in preparation for i8/i16 atomic xchg support. >> >> The architectures supporting Rust, implement atomic xchg families >> using architecture-specific instructions. So the helpers just call >> them. >> >> Note that the architectures that support Rust handle xchg differently: >> >> - arm64 and riscv support xchg with all the orderings. >> >> - x86_64 and loongarch support only full-ordering xchg. They calls the >> full-ordering xchg for any orderings. >> >> - arm v7 supports only relaxed-odering xchg. It uses __atomic_op_ >> macros to add barriers properly. >> > > Thanks for the work! And please do Cc linux-arch next time when doing > architecture-related changes. We would get more experts to take a look. Will do, thanks. > I think the current implementation expects that xchg() work with normal > store/load, and that requires ARCH_SUPPORTS_ATOMIC_RMW. So could you add > a comment saying the current implementation only support > ARCH_SUPPORTS_ATOMIC_RMW architectures? And when you wire up the rust > helpers, I think using #[cfg(CONFIG_ARCH_SUPPORTS_ATOMIC_RMW)] is a good > idea. This will at least let the !ARCH_SUPPORTS_ATOMIC_RMW archs know > that something is missing here. I will add a comment. ARCH_SUPPORTS_ATOMIC_RMW is required, but we also rely on xchg supporting i8/i16, which is not currently required on the C side, I suppose. As I wrote, at the moment, the architectures that support Rust (x86_64, armv7, arm64, riscv, and loongarch) satisfy these requirements, so my plan was to use cfgs in internal.rs to restrict xchg support to those architectures. ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-18 11:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20251217213742.639812-1-fujita.tomonori@gmail.com>
2025-12-18 9:18 ` [PATCH v1 0/4] rust: Add i8/i16 atomic xchg helpers Boqun Feng
2025-12-18 11:08 ` FUJITA Tomonori
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox