From patchwork Mon Sep 4 14:28:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 9937267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C4186601EB for ; Mon, 4 Sep 2017 14:37:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A76AA28794 for ; Mon, 4 Sep 2017 14:37:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C33828806; Mon, 4 Sep 2017 14:37:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5831028803 for ; Mon, 4 Sep 2017 14:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753773AbdIDOg7 (ORCPT ); Mon, 4 Sep 2017 10:36:59 -0400 Received: from charybdis-ext.suse.de ([195.135.221.2]:49508 "EHLO suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753633AbdIDOg6 (ORCPT ); Mon, 4 Sep 2017 10:36:58 -0400 X-Greylist: delayed 486 seconds by postgrey-1.27 at vger.kernel.org; Mon, 04 Sep 2017 10:36:57 EDT Received: by suse.de (Postfix, from userid 1000) id 9A0E3E44; Mon, 4 Sep 2017 16:28:50 +0200 (CEST) From: Oscar Salvador To: Ingo Molnar , Paolo Bonzini , Peter Zijlstra , "H . Peter Anvin" , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, Oscar Salvador , Waiman Long Subject: [PATCH resend] x86, kvm: Add a kernel parameter to disable PV spinlock Date: Mon, 4 Sep 2017 16:28:36 +0200 Message-Id: <20170904142836.15446-1-osalvador@suse.de> X-Mailer: git-send-email 2.13.5 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is just a resend of Waiman Long's patch. I could not find why it was not merged to upstream, so I thought to give it another chance. What follows is what Waiman Long wrote. 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 Signed-off-by: Oscar Salvador --- Documentation/admin-guide/kernel-parameters.txt | 6 +++++- arch/x86/kernel/kvm.c | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index d9c171ce4190..56c6e3acdf8e 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1899,6 +1899,10 @@ 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] @@ -4533,7 +4537,7 @@ 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 d04e30e3c0ff..51addf874fc1 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -568,6 +568,18 @@ 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); + #include static void kvm_wait(u8 *ptr, u8 val) @@ -633,7 +645,7 @@ asm( */ 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))