From: Heiko Carstens Date: Wed, 6 Nov 2024 10:03:14 +0000 (+0100) Subject: s390/preempt: Use arch_try_cmpxchg() instead of __atomic_cmpxchg() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=75a98ed6faa03656811922cd383994fa7c300259;p=users%2Fjedix%2Flinux-maple.git s390/preempt: Use arch_try_cmpxchg() instead of __atomic_cmpxchg() 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 Signed-off-by: Heiko Carstens --- diff --git a/arch/s390/include/asm/preempt.h b/arch/s390/include/asm/preempt.h index deca3f221836e..0cde7e2403736 100644 --- a/arch/s390/include/asm/preempt.h +++ b/arch/s390/include/asm/preempt.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #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)