From: Heiko Carstens Date: Wed, 6 Nov 2024 10:03:13 +0000 (+0100) Subject: s390/atomic: Provide arch_atomic_try_cmpxchg() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=5ba865ad579c6a7efc8f17dab760478a4c5eec66;p=users%2Fjedix%2Flinux-maple.git s390/atomic: Provide arch_atomic_try_cmpxchg() Since gcc 14 flag output operands are supported also for s390. Provide an arch_atomic try_cmpxchg() implementation so that all existing atomic_try_cmpxchg() usages generate slightly better code, if compiled with gcc 14 or newer. Reviewed-by: Juergen Christ Signed-off-by: Heiko Carstens --- diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h index 38e81fb7e066b..6723fca640182 100644 --- a/arch/s390/include/asm/atomic.h +++ b/arch/s390/include/asm/atomic.h @@ -84,6 +84,12 @@ static __always_inline int arch_atomic_cmpxchg(atomic_t *v, int old, int new) } #define arch_atomic_cmpxchg arch_atomic_cmpxchg +static __always_inline bool arch_atomic_try_cmpxchg(atomic_t *v, int *old, int new) +{ + return arch_try_cmpxchg(&v->counter, old, new); +} +#define arch_atomic_try_cmpxchg arch_atomic_try_cmpxchg + #define ATOMIC64_INIT(i) { (i) } static __always_inline s64 arch_atomic64_read(const atomic64_t *v) @@ -128,6 +134,12 @@ static __always_inline s64 arch_atomic64_cmpxchg(atomic64_t *v, s64 old, s64 new } #define arch_atomic64_cmpxchg arch_atomic64_cmpxchg +static __always_inline bool arch_atomic64_try_cmpxchg(atomic64_t *v, s64 *old, s64 new) +{ + return arch_try_cmpxchg(&v->counter, old, new); +} +#define arch_atomic64_try_cmpxchg arch_atomic64_try_cmpxchg + #define ATOMIC64_OPS(op) \ static __always_inline void arch_atomic64_##op(s64 i, atomic64_t *v) \ { \