mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86,kvm: Add a kernel parameter to disable PV spinlock
@ 2015-07-11 20:44 Waiman Long
  0 siblings, 0 replies; only message in thread
From: Waiman Long @ 2015-07-11 20:44 UTC (permalink / raw)
  To: Jonathan Corbet, Gleb Natapov, Paolo Bonzini, Ingo Molnar,
	Thomas Gleixner, H. Peter Anvin
  Cc: x86, kvm, linux-kernel, linux-doc, Peter Zijlstra,
	Scott J Norton, Douglas Hatch, Waiman Long

Xen has an kernel command line argument "xen_nopvspin" to disable
paravirtual spinlocks. This patch adds a similar "kvm_nopvspin"
argument to disable paravirtual spinlocks for KVM. This can be useful
for testing as well as allowing administrators to choose unfair lock
for their KVM guests if they want to.

Signed-off-by: Waiman Long <Waiman.Long@hp.com>
---
 Documentation/kernel-parameters.txt |    7 ++++++-
 arch/x86/kernel/kvm.c               |   15 +++++++++++++--
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 1d6f045..032d37d 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1747,6 +1747,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			feature (tagged TLBs) on capable Intel chips.
 			Default is 1 (enabled)
 
+	kvm_nopvspin	[X86,KVM]
+			Disables the paravirtualized spinlock slowpath
+			optimizations for KVM.
+
+
 	l2cr=		[PPC]
 
 	l3cr=		[PPC]
@@ -4091,7 +4096,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			never -- do not unplug even if version check succeeds
 
 	xen_nopvspin	[X86,XEN]
-			Disables the ticketlock slowpath using Xen PV
+			Disables the spinlock slowpath using Xen PV
 			optimizations.
 
 	xen_nopv	[X86]
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 47190bd..6373dca 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -584,6 +584,17 @@ static void kvm_kick_cpu(int cpu)
 	kvm_hypercall2(KVM_HC_KICK_CPU, flags, apicid);
 }
 
+static bool kvm_pvspin = true;
+
+/*
+ * Allow disabling of PV spinlock in kernel command line
+ */
+static __init int kvm_parse_nopvspin(char *arg)
+{
+	kvm_pvspin = false;
+	return 0;
+}
+early_param("kvm_nopvspin", kvm_parse_nopvspin);
 
 #ifdef CONFIG_QUEUED_SPINLOCKS
 
@@ -857,7 +868,7 @@ static void kvm_unlock_kick(struct arch_spinlock *lock, __ticket_t ticket)
  */
 void __init kvm_spinlock_init(void)
 {
-	if (!kvm_para_available())
+	if (!kvm_para_available() || !kvm_pvspin)
 		return;
 	/* Does host kernel support KVM_FEATURE_PV_UNHALT? */
 	if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT))
@@ -877,7 +888,7 @@ void __init kvm_spinlock_init(void)
 
 static __init int kvm_spinlock_init_jump(void)
 {
-	if (!kvm_para_available())
+	if (!kvm_para_available() || !kvm_pvspin)
 		return 0;
 	if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT))
 		return 0;
-- 
1.7.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-07-11 20:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-11 20:44 [PATCH] x86,kvm: Add a kernel parameter to disable PV spinlock Waiman Long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®