s390/preempt: Optimize __preempt_count_dec_and_test()
authorHeiko Carstens <hca@linux.ibm.com>
Wed, 11 Dec 2024 11:58:05 +0000 (12:58 +0100)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Sun, 15 Dec 2024 15:19:03 +0000 (16:19 +0100)
Use __atomic_add_const_and_test() within __preempt_count_dec_and_test().
With this it is possible to decrease preempt_count by one and test if
need_resched is set with one instruction, if the compiler has support for
flag output operand constraints.

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

index a55e1767b4d43812aafc263ed9e0cffd7f3b9fb5..6ccd033acfe52f5044e8b51623c700856506df92 100644 (file)
@@ -87,7 +87,7 @@ static __always_inline void __preempt_count_sub(int val)
  */
 static __always_inline bool __preempt_count_dec_and_test(void)
 {
-       return __atomic_add(-1, &get_lowcore()->preempt_count) == 1;
+       return __atomic_add_const_and_test(-1, &get_lowcore()->preempt_count);
 }
 
 /*