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

index 38e81fb7e066bc3de21b7daa2a7ae74a83f92fd0..6723fca640182118943a53b1b8676d2f463c15ba 100644 (file)
@@ -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)           \
 {                                                                              \