[PATCH] x86,kvm: Add a kernel parameter to disable PV spinlock
From: Waiman Long
Date: Sat Jul 11 2015 - 16:44:37 EST
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@xxxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/