aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/paravirt.c
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2008-07-07 15:07:51 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-16 05:15:53 -0400
commit8efcbab674de2bee45a2e4cdf97de16b8e609ac8 (patch)
tree1b45a9446e471bfdba21e7982c87aef47d2f8313 /arch/x86/kernel/paravirt.c
parent74d4affde8feb8d5bdebf7fba8e90e4eae3b7b1d (diff)
paravirt: introduce a "lock-byte" spinlock implementation
Implement a version of the old spinlock algorithm, in which everyone spins waiting for a lock byte. In order to be compatible with the ticket-lock's use of a zero initializer, this uses the convention of '0' for unlocked and '1' for locked. This algorithm is much better than ticket locks in a virtual envionment, because it doesn't interact badly with the vcpu scheduler. If there are multiple vcpus spinning on a lock and the lock is released, the next vcpu to be scheduled will take the lock, rather than cycling around until the next ticketed vcpu gets it. To use this, you must call paravirt_use_bytelocks() very early, before any spinlocks have been taken. 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>
Diffstat (limited to 'arch/x86/kernel/paravirt.c')
-rw-r--r--arch/x86/kernel/paravirt.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index f33816868707..bba4041bb7ff 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -268,6 +268,15 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
268 return __get_cpu_var(paravirt_lazy_mode); 268 return __get_cpu_var(paravirt_lazy_mode);
269} 269}
270 270
271void __init paravirt_use_bytelocks(void)
272{
273 pv_lock_ops.spin_is_locked = __byte_spin_is_locked;
274 pv_lock_ops.spin_is_contended = __byte_spin_is_contended;
275 pv_lock_ops.spin_lock = __byte_spin_lock;
276 pv_lock_ops.spin_trylock = __byte_spin_trylock;
277 pv_lock_ops.spin_unlock = __byte_spin_unlock;
278}
279
271struct pv_info pv_info = { 280struct pv_info pv_info = {
272 .name = "bare hardware", 281 .name = "bare hardware",
273 .paravirt_enabled = 0, 282 .paravirt_enabled = 0,