From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933331AbdKPEy1 (ORCPT ); Wed, 15 Nov 2017 23:54:27 -0500 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]:1071 "EHLO smtp-fw-9102.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932420AbdKPEyR (ORCPT ); Wed, 15 Nov 2017 23:54:17 -0500 X-IronPort-AV: E=Sophos;i="5.44,402,1505779200"; d="scan'208";a="573757143" Date: Wed, 15 Nov 2017 20:54:07 -0800 From: Eduardo Valentin To: Radim =?utf-8?B?S3LEjW3DocWZ?= CC: Eduardo Valentin , Paolo Bonzini , Matt Wilson , Jonathan Corbet , "Thomas Gleixner" , Ingo Molnar , "H. Peter Anvin" , , Peter Zijlstra , Waiman Long , , , , "Jan H . Schoenherr" , Anthony Liguori Subject: Re: [PATCHv3 1/1] locking/qspinlock/x86: Avoid test-and-set when PV_DEDICATED is set Message-ID: <20171116045407.GF14563@u40b0340c692b58f6553c.ant.amazon.com> References: <1509999980-10828-1-git-send-email-eduval@amazon.com> <20171108173651.GA3664@flask> <20171109085547.GA5107@u40b0340c692b58f6553c.ant.amazon.com> <20171109141732.GA20859@flask> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20171109141732.GA20859@flask> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey Radim, On Thu, Nov 09, 2017 at 03:17:33PM +0100, Radim Krčmář wrote: > > This is what I'm doubting, because the patch is adding about two > thousand cycles to every spinlock-taken path. > Doesn't this patch yield better results? > > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > index 3df743b60c80..d9225e48c11a 100644 > --- a/arch/x86/kernel/kvm.c > +++ b/arch/x86/kernel/kvm.c > @@ -676,6 +676,12 @@ void __init kvm_spinlock_init(void) > { > if (!kvm_para_available()) > return; > + > + if (kvm_para_has_feature(KVM_FEATURE_PV_DEDICATED)) { > + static_branch_disable(&virt_spin_lock_key); > + return; > + } > + Yes, the above suggestion is a much better approach. The code has probably changed from the time I wrote the first version. I will refresh with the above suggestion. > /* Does host kernel support KVM_FEATURE_PV_UNHALT? */ > if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT)) > return; > > > However, the key aspect > > here is this patch gives a way for the host to instruct the guest to use qspinlock. > > Even with Longman's patch which allows guest to select the spinlock implementation, > > there should still be the auto-select mode. In such mode, PV_DEDICATED should > > allow the host to get the guest to use qspinlock, without, the guest will fallback > > to tas when PV_UNHALT == 0. > > I agree that a flag can be useful for certains setups. Cool! > -- All the best, Eduardo Valentin