diff options
author | Heiko Carstens <hca@linux.ibm.com> | 2024-11-06 11:03:10 +0100 |
---|---|---|
committer | Heiko Carstens <hca@linux.ibm.com> | 2024-11-12 14:01:28 +0100 |
commit | c76b3bc28577b1be5ce8042d573e833f133d459a (patch) | |
tree | fdad5445166382b0a34b3efc5936df75dd6b795d /arch/s390 | |
parent | de9e2eb89175dd1ad469514f4a710fffe01efd86 (diff) | |
download | linux-stable-c76b3bc28577b1be5ce8042d573e833f133d459a.tar.gz linux-stable-c76b3bc28577b1be5ce8042d573e833f133d459a.tar.bz2 linux-stable-c76b3bc28577b1be5ce8042d573e833f133d459a.zip |
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 <jchrist@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/include/asm/cmpxchg.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/arch/s390/include/asm/cmpxchg.h b/arch/s390/include/asm/cmpxchg.h index 9407e6494afa..a9e2006033b7 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 */ |