]> git.karo-electronics.de Git - karo-tx-linux.git/commit
x86, ticketlock: Convert spin loop to C
authorJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Fri, 24 Jun 2011 01:19:14 +0000 (18:19 -0700)
committerH. Peter Anvin <hpa@linux.intel.com>
Fri, 22 Jul 2011 18:13:26 +0000 (11:13 -0700)
commit79e661791e9681d31fe32dfebe6d2fcf4938b64b
tree9c7af8ef9ae6bf880ed1c7fd106722f8f9e0f57a
parent699f3dd4e4f8fba6ded83a3dc21e3db960323fcc
x86, ticketlock: Convert spin loop to C

The inner loop of __ticket_spin_lock isn't doing anything very special,
so reimplement it in C.

For the 8 bit ticket lock variant, we use a register union to get direct
access to the lower and upper bytes in the tickets, but unfortunately gcc
won't generate a direct comparison between the two halves of the register,
so the generated asm isn't quite as pretty as the hand-coded version.
However benchmarking shows that this is actually a small improvement in
runtime performance on some benchmarks, and never a slowdown.

We also need to make sure there's a barrier at the end of the lock loop
to make sure that the compiler doesn't move any instructions from within
the locked region into the region where we don't yet own the lock.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Link: http://lkml.kernel.org/r/f04120629b8b1cfa1c306373e34320687305a518.1308878118.git.jeremy.fitzhardinge@citrix.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
arch/x86/include/asm/spinlock.h