From: Heiko Carstens Date: Wed, 6 Nov 2024 10:03:10 +0000 (+0100) Subject: s390/cmpxchg: Provide arch_try_cmpxchg128() X-Git-Tag: v6.13-rc1~206^2~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c76b3bc28577b1be5ce8042d573e833f133d459a;p=thirdparty%2Fkernel%2Flinux.git s390/cmpxchg: Provide arch_try_cmpxchg128() Since gcc 14 flag output operands are supported also for s390. Provide an arch_try_cmpxchg128() implementation so that all existing try_cmpxchg128() variants provide 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/cmpxchg.h b/arch/s390/include/asm/cmpxchg.h index 9407e6494afa4..a9e2006033b77 100644 --- a/arch/s390/include/asm/cmpxchg.h +++ b/arch/s390/include/asm/cmpxchg.h @@ -251,4 +251,23 @@ static __always_inline u128 arch_cmpxchg128(volatile u128 *ptr, u128 old, u128 n #define arch_cmpxchg128 arch_cmpxchg128 #define arch_cmpxchg128_local arch_cmpxchg128 +#ifdef __HAVE_ASM_FLAG_OUTPUTS__ + +static __always_inline bool arch_try_cmpxchg128(volatile u128 *ptr, u128 *oldp, u128 new) +{ + int cc; + + asm volatile( + " cdsg %[old],%[new],%[ptr]\n" + : [old] "+d" (*oldp), [ptr] "+QS" (*ptr), "=@cc" (cc) + : [new] "d" (new) + : "memory"); + return likely(cc == 0); +} + +#define arch_try_cmpxchg128 arch_try_cmpxchg128 +#define arch_try_cmpxchg128_local arch_try_cmpxchg128 + +#endif /* __HAVE_ASM_FLAG_OUTPUTS__ */ + #endif /* __ASM_CMPXCHG_H */