]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/cmpxchg: Provide arch_try_cmpxchg128()
authorHeiko Carstens <hca@linux.ibm.com>
Wed, 6 Nov 2024 10:03:10 +0000 (11:03 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Tue, 12 Nov 2024 13:01:28 +0000 (14:01 +0100)
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>
arch/s390/include/asm/cmpxchg.h

index 9407e6494afa47dcafb48738335582b217204b8f..a9e2006033b77ff371168aee29880c77e679eab1 100644 (file)
@@ -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 */