linux/arch
Jeremy Fitzhardinge 2d9e1e2f58 xen: implement Xen-specific spinlocks
The standard ticket spinlocks are very expensive in a virtual
environment, because their performance depends on Xen's scheduler
giving vcpus time in the order that they're supposed to take the
spinlock.

This implements a Xen-specific spinlock, which should be much more
efficient.

The fast-path is essentially the old Linux-x86 locks, using a single
lock byte.  The locker decrements the byte; if the result is 0, then
they have the lock.  If the lock is negative, then locker must spin
until the lock is positive again.

When there's contention, the locker spin for 2^16[*] iterations waiting
to get the lock.  If it fails to get the lock in that time, it adds
itself to the contention count in the lock and blocks on a per-cpu
event channel.

When unlocking the spinlock, the locker looks to see if there's anyone
blocked waiting for the lock by checking for a non-zero waiter count.
If there's a waiter, it traverses the per-cpu "lock_spinners"
variable, which contains which lock each CPU is waiting on.  It picks
one CPU waiting on the lock and sends it an event to wake it up.

This allows efficient fast-path spinlock operation, while allowing
spinning vcpus to give up their processor time while waiting for a
contended lock.

[*] 2^16 iterations is threshold at which 98% locks have been taken
according to Thomas Friebel's Xen Summit talk "Preventing Guests from
Spinning Around".  Therefore, we'd expect the lock and unlock slow
paths will only be entered 2% of the time.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Christoph Lameter <clameter@linux-foundation.org>
Cc: Petr Tesarik <ptesarik@suse.cz>
Cc: Virtualization <virtualization@lists.linux-foundation.org>
Cc: Xen devel <xen-devel@lists.xensource.com>
Cc: Thomas Friebel <thomas.friebel@amd.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2008-07-16 11:15:53 +02:00
..
alpha Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
arm Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
avr32 Merge branch 'core/stacktrace' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-07-15 10:31:35 -07:00
blackfin Merge commit 'v2.6.26' into bkl-removal 2008-07-14 15:29:34 -06:00
cris Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
frv Fix various old email addresses for dwmw2 2008-06-06 11:29:10 -07:00
h8300 [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
ia64 Merge branch 'generic-ipi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-07-15 14:12:03 -07:00
m32r smp_call_function: get rid of the unused nonatomic/retry argument 2008-06-26 11:24:35 +02:00
m68k Merge commit 'v2.6.26' into bkl-removal 2008-07-14 15:29:34 -06:00
m68knommu m68knommu: init coldfire timer TRR with n - 1, not n 2008-06-12 18:05:40 -07:00
mips Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus 2008-07-15 15:01:29 -07:00
mn10300 mn10300: provide __ucmpdi2() for MN10300 2008-07-04 10:40:07 -07:00
parisc Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
powerpc Merge commit 'origin/master' 2008-07-16 11:07:59 +10:00
s390 generic-ipi: more merge fallout 2008-07-15 22:08:52 +02:00
sh Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
sparc Merge commit 'v2.6.26' into bkl-removal 2008-07-14 15:29:34 -06:00
sparc64 Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
um Merge branch 'generic-ipi' into generic-ipi-for-linus 2008-07-15 21:55:59 +02:00
v850 [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
x86 xen: implement Xen-specific spinlocks 2008-07-16 11:15:53 +02:00
xtensa [PATCH] take init_files to fs/file.c 2008-05-16 17:22:20 -04:00
.gitignore
Kconfig Add generic helpers for arch IPI function calls 2008-06-26 11:21:34 +02:00