From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751518AbdIEI2O (ORCPT ); Tue, 5 Sep 2017 04:28:14 -0400 Received: from merlin.infradead.org ([205.233.59.134]:49998 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751070AbdIEI2K (ORCPT ); Tue, 5 Sep 2017 04:28:10 -0400 Date: Tue, 5 Sep 2017 10:28:01 +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: <20170905082801.d3sr7hdjz6lpon5p@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <83ac209b-0807-0a72-cd07-d4ccd1d1ed61@suse.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 05, 2017 at 10:14:21AM +0200, Juergen Gross wrote: > On 05/09/17 10:10, Peter Zijlstra wrote: > > On Tue, Sep 05, 2017 at 09:35:40AM +0200, Juergen Gross wrote: > >>> So the problem with qspinlock is that it will revert to a classic > >>> test-and-set spinlock if you don't do paravirt but are running a HV. > >> > >> In the Xen case we just use the bare metal settings when xen_nopvspin > >> has been specified. So paravirt, but without modifying any pv_lock_ops > >> functions. > > > > See arch/x86/include/asm/qspinlock.h:virt_spin_lock(). Unless you clear > > X86_FEATURE_HYPERVISOR you get a test-and-set spinlock. > > > > And as the comment there says, this is a fallback for !paravirt enabled > > hypervisors to avoid the worst of the lock holder preemption crud. > > > > But this very much does not deal with the 1:1 case nicely. > > > > Aah, now I've got it. > > So maybe we should add virt_spin_lock() to pv_lock_ops? This way e.g. > xen_nopvspin could tweak just the virt_spin_lock() case by letting it > return false all the time? 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.