Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751703AbbGKUo2 (ORCPT ); Sat, 11 Jul 2015 16:44:28 -0400 Received: from g4t3427.houston.hp.com ([15.201.208.55]:39078 "EHLO g4t3427.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751346AbbGKUo0 (ORCPT ); Sat, 11 Jul 2015 16:44:26 -0400 From: Waiman Long To: Jonathan Corbet , Gleb Natapov , Paolo Bonzini , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" Cc: x86@kernel.org, kvm@kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Peter Zijlstra , Scott J Norton , Douglas Hatch , Waiman Long Subject: [PATCH] x86,kvm: Add a kernel parameter to disable PV spinlock Date: Sat, 11 Jul 2015 16:44:19 -0400 Message-Id: <1436647459-49869-1-git-send-email-Waiman.Long@hp.com> X-Mailer: git-send-email 1.7.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2730 Lines: 85 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 --- 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/