]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
s390/preempt: Optimize __preempt_count_dec_and_test()
authorHeiko Carstens <hca@linux.ibm.com>
Tue, 13 Jan 2026 19:44:00 +0000 (20:44 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Sat, 17 Jan 2026 14:52:49 +0000 (15:52 +0100)
commit48b4790f054994d4df6d1025ec9267b19618f0ec
tree0333bbd118d452d31e0e833efe9a9d9e9902ff3e
parent05405b8fd284189278636a0392976cbec3bb6d19
s390/preempt: Optimize __preempt_count_dec_and_test()

Provide an inline assembly using alternatives to avoid the need of a
base register due to relocatable lowcore when adding or subtracting
small constants from preempt_count.

Main user is preempt_enable(), which subtracts one from preempt_count
and tests if the result is zero.

With this the generated code changes from

  1000b8:       a7 19 00 00             lghi    %r1,0
  1000bc:       eb ff 13 a8 00 6e       alsi    936(%r1),-1
  1000c2:       a7 54 00 05             jnhe    1000cc <__rcu_read_unlock+0x14>

to something like this:

  1000b8:       eb ff 03 a8 00 6e       alsi    936,-1
  1000be:       a7 54 00 05             jnhe    1000c8 <__rcu_read_unlock+0x10>

Kernel image size is reduced by 45kb (bloat-o-meter -t, defconfig, gcc15).

Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/include/asm/preempt.h