mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Waiman Long <Waiman.Long@hp.com>
To: Jonathan Corbet <corbet@lwn.net>, Gleb Natapov <gleb@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org, kvm@kernel.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>,
	Scott J Norton <scott.norton@hp.com>,
	Douglas Hatch <doug.hatch@hp.com>,
	Waiman Long <Waiman.Long@hp.com>
Subject: [PATCH] x86,kvm: Add a kernel parameter to disable PV spinlock
Date: Sat, 11 Jul 2015 16:44:19 -0400	[thread overview]
Message-ID: <1436647459-49869-1-git-send-email-Waiman.Long@hp.com> (raw)

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


                 reply	other threads:[~2015-07-11 20:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436647459-49869-1-git-send-email-Waiman.Long@hp.com \
    --to=waiman.long@hp.com \
    --cc=corbet@lwn.net \
    --cc=doug.hatch@hp.com \
    --cc=gleb@kernel.org \
    --cc=hpa@zytor.com \
    --cc=kvm@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=scott.norton@hp.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®