[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171116045407.GF14563@u40b0340c692b58f6553c.ant.amazon.com>
Date: Wed, 15 Nov 2017 20:54:07 -0800
From: Eduardo Valentin <eduval@...zon.com>
To: Radim Krčmář <rkrcmar@...hat.com>
CC: Eduardo Valentin <eduval@...zon.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Matt Wilson <msw@...zon.com>, Jonathan Corbet <corbet@....net>,
"Thomas Gleixner" <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, <x86@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Waiman Long <longman@...hat.com>, <kvm@...r.kernel.org>,
<linux-doc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
"Jan H . Schoenherr" <jschoenh@...zon.de>,
Anthony Liguori <aliguori@...zon.com>
Subject: Re: [PATCHv3 1/1] locking/qspinlock/x86: Avoid test-and-set when
PV_DEDICATED is set
Hey Radim,
On Thu, Nov 09, 2017 at 03:17:33PM +0100, Radim Krčmář wrote:
<cut>
>
> 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
Powered by blists - more mailing lists