]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
locking/spinlocks: Remove an instruction from spin and write locks
authorMatthew Wilcox <willy@infradead.org>
Mon, 20 Aug 2018 14:19:14 +0000 (10:19 -0400)
committerIngo Molnar <mingo@kernel.org>
Tue, 2 Oct 2018 07:49:42 +0000 (09:49 +0200)
commit27df89689e257cccb604fdf56c91a75a25aa554a
tree783e97bf76ae8c269f28e59f21ec62c6dc3dfa3f
parentcb92173d1f0474784c6171a9d3fdbbca0ee53554
locking/spinlocks: Remove an instruction from spin and write locks

Both spin locks and write locks currently do:

 f0 0f b1 17             lock cmpxchg %edx,(%rdi)
 85 c0                   test   %eax,%eax
 75 05                   jne    [slowpath]

This 'test' insn is superfluous; the cmpxchg insn sets the Z flag
appropriately.  Peter pointed out that using atomic_try_cmpxchg_acquire()
will let the compiler know this is true.  Comparing before/after
disassemblies show the only effect is to remove this insn.

Take this opportunity to make the spin & write lock code resemble each
other more closely and have similar likely() hints.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Will Deacon <will.deacon@arm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Waiman Long <longman@redhat.com>
Link: http://lkml.kernel.org/r/20180820162639.GC25153@bombadil.infradead.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
include/asm-generic/qrwlock.h
include/asm-generic/qspinlock.h