]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/preempt: Use arch_try_cmpxchg() instead of __atomic_cmpxchg()
authorHeiko Carstens <hca@linux.ibm.com>
Wed, 6 Nov 2024 10:03:14 +0000 (11:03 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Tue, 12 Nov 2024 13:01:29 +0000 (14:01 +0100)
Use arch_try_cmpxchg() instead of __atomic_cmpxchg() in
preempt_count_set() to generate similar or better code,
depending in compiler features.

Reviewed-by: Juergen Christ <jchrist@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/include/asm/preempt.h

index deca3f221836ed1ec4dfcea7f56d3d6e51510601..0cde7e2403736a31aab6614806a84badee8c79c9 100644 (file)
@@ -5,6 +5,7 @@
 #include <asm/current.h>
 #include <linux/thread_info.h>
 #include <asm/atomic_ops.h>
+#include <asm/cmpxchg.h>
 #include <asm/march.h>
 
 #ifdef MARCH_HAS_Z196_FEATURES
@@ -22,12 +23,10 @@ static __always_inline void preempt_count_set(int pc)
 {
        int old, new;
 
+       old = READ_ONCE(get_lowcore()->preempt_count);
        do {
-               old = READ_ONCE(get_lowcore()->preempt_count);
-               new = (old & PREEMPT_NEED_RESCHED) |
-                       (pc & ~PREEMPT_NEED_RESCHED);
-       } while (__atomic_cmpxchg(&get_lowcore()->preempt_count,
-                                 old, new) != old);
+               new = (old & PREEMPT_NEED_RESCHED) | (pc & ~PREEMPT_NEED_RESCHED);
+       } while (!arch_try_cmpxchg(&get_lowcore()->preempt_count, &old, new));
 }
 
 static __always_inline void set_preempt_need_resched(void)