From patchwork Tue Sep 5 09:03:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 9938273 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 6CEDC601EB for ; Tue, 5 Sep 2017 09:03:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E9B0274D2 for ; Tue, 5 Sep 2017 09:03:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5288E2868D; Tue, 5 Sep 2017 09:03:22 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham 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 DA69A274D2 for ; Tue, 5 Sep 2017 09:03:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751733AbdIEJDU (ORCPT ); Tue, 5 Sep 2017 05:03:20 -0400 Received: from merlin.infradead.org ([205.233.59.134]:50624 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751583AbdIEJDQ (ORCPT ); Tue, 5 Sep 2017 05:03:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=QoPGTWSz1rQ7ewMXD3Iz6hCJCQHxqoOr5+HKP09Pi5g=; b=lSkrxLSrIyV5E0VrrljkulKv3 lLxGqbvkWd0Mzm5LyJ7gE28msUjDV59s7QmSYJTsCv1rkJiA5Z/qDcwdBYy8/0Rm/iaELM5GHwUKT jeuwCqx3pbf9sYA649K3vb5XJJr41yinRTkEegdbY78tkOLnT3kcpFvkSriZO3Ig++F/eDPlOATWw Lxl8SMaNRN0yQaW0xMmN4ZgBYSEZeHJ1CVGARgVl/os7xSRn3p2lOuGTkEOwEPinGc9+e/Bzo95cx 9BO8EH8jjdBpCoGwCjdStk68WBNoTZGkAJvRQ1clkBNEum4Nbh8LvcoEJPR8Tob/UCiS0iNMPvejV 78AhQ3jng==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dp9lD-0005su-Eh; Tue, 05 Sep 2017 09:03:08 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 355C220288389; Tue, 5 Sep 2017 11:03:06 +0200 (CEST) Date: Tue, 5 Sep 2017 11:03:06 +0200 From: Peter Zijlstra To: Juergen Gross Cc: Davidlohr Bueso , Oscar Salvador , Ingo Molnar , Paolo Bonzini , "H . Peter Anvin" , Thomas Gleixner , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, Waiman Long Subject: Re: [PATCH resend] x86,kvm: Add a kernel parameter to disable PV spinlock Message-ID: <20170905090306.gz52hlo7s2ybogoy@hirez.programming.kicks-ass.net> References: <20170904142836.15446-1-osalvador@suse.de> <20170904144011.gp7hpis6usjehbuf@hirez.programming.kicks-ass.net> <20170904222157.GD17982@linux-80c1.suse> <0869e8a5-4abd-8f7f-0135-aab3e72e2d01@suse.com> <20170905065837.rs767a4os2aumg7h@hirez.programming.kicks-ass.net> <924fec17-548a-083d-edce-7adcb662c513@suse.com> <20170905081001.hn2276qrhfyqpjdi@hirez.programming.kicks-ass.net> <83ac209b-0807-0a72-cd07-d4ccd1d1ed61@suse.com> <20170905082801.d3sr7hdjz6lpon5p@hirez.programming.kicks-ass.net> <1b3afce5-c95d-5a3a-c36c-953a0654ab2d@suse.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1b3afce5-c95d-5a3a-c36c-953a0654ab2d@suse.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Sep 05, 2017 at 10:52:06AM +0200, Juergen Gross wrote: > > Hmm, that might work. Could we somehow nop that call when > > !X86_FEATURE_HYPERVISOR?, that saves native from having to do the call > > and would be a win for everyone. > > So in fact we want a "always false" shortcut for bare metal and for any > virtualization environment selecting bare metal behavior. > > I'll have a try. Right, so for native I think you can do this: diff --git a/arch/x86/kernel/paravirt_patch_64.c b/arch/x86/kernel/paravirt_patch_64.c index 11aaf1eaa0e4..4e9839001291 100644 --- a/arch/x86/kernel/paravirt_patch_64.c +++ b/arch/x86/kernel/paravirt_patch_64.c @@ -21,6 +21,7 @@ DEF_NATIVE(, mov64, "mov %rdi, %rax"); #if defined(CONFIG_PARAVIRT_SPINLOCKS) DEF_NATIVE(pv_lock_ops, queued_spin_unlock, "movb $0, (%rdi)"); DEF_NATIVE(pv_lock_ops, vcpu_is_preempted, "xor %rax, %rax"); +DEF_NATIVE(pv_lock_ops, virt_spin_lock, "xor %rax, %rax"); #endif unsigned paravirt_patch_ident_32(void *insnbuf, unsigned len) @@ -77,6 +78,13 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf, goto patch_site; } goto patch_default; + case PARAVIRT_PATCH(pv_lock_ops.virt_spin_lock): + if (!this_cpu_has(X86_FEATURE_HYPERVISOR)) { + start = start_pv_lock_ops_virt_spin_lock; + end = end_pv_lock_ops_virt_spin_lock; + goto patch_side; + } + goto patch_default; #endif default: