x86, ticketlock: Convert spin loop to C
commitc576a3ea905c25d50339503e0e5c7fef724e0147
authorJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Sat, 3 Jul 2010 00:06:04 +0000 (3 01:06 +0100)
committerH. Peter Anvin <hpa@linux.intel.com>
Mon, 29 Aug 2011 20:45:43 +0000 (29 13:45 -0700)
treecce69d03234f842428f42518aca329a38862207c
parent84eb950db13ca40a0572ce9957e14723500943d6
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/4E5BCC40.3030501@goop.org
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
arch/x86/include/asm/spinlock.h