[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4e1ef1d3-527b-bb70-5536-d9daeb50b7c7@oracle.com>
Date: Mon, 14 Oct 2019 09:52:59 +0800
From: Zhenzhong Duan <zhenzhong.duan@...cle.com>
To: Vitaly Kuznetsov <vkuznets@...hat.com>,
linux-kernel@...r.kernel.org
Cc: linux-hyperv@...r.kernel.org, kvm@...r.kernel.org,
kys@...rosoft.com, haiyangz@...rosoft.com, sthemmin@...rosoft.com,
sashal@...nel.org, tglx@...utronix.de, mingo@...hat.com,
bp@...en8.de, pbonzini@...hat.com, rkrcmar@...hat.com,
sean.j.christopherson@...el.com, wanpengli@...cent.com,
jmattson@...gle.com, joro@...tes.org, boris.ostrovsky@...cle.com,
jgross@...e.com, sstabellini@...nel.org, peterz@...radead.org,
Jonathan Corbet <corbet@....net>,
"H. Peter Anvin" <hpa@...or.com>, Will Deacon <will@...nel.org>
Subject: Re: [PATCH v5 3/5] x86/kvm: Add "nopvspin" parameter to disable PV
spinlocks
On 2019/10/13 17:02, Vitaly Kuznetsov wrote:
> Zhenzhong Duan <zhenzhong.duan@...cle.com> writes:
...snip
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index ef836d6..6e14bd4 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -825,18 +825,31 @@ __visible bool __kvm_vcpu_is_preempted(long cpu)
> */
> void __init kvm_spinlock_init(void)
> {
> - /* Does host kernel support KVM_FEATURE_PV_UNHALT? */
> - if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT))
> + /*
> + * Disable PV qspinlocks if host kernel doesn't support
> + * KVM_FEATURE_PV_UNHALT feature or there is only 1 vCPU.
> + * virt_spin_lock_key is enabled to avoid lock holder
> + * preemption issue.
> + */
> + if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT) ||
> + num_possible_cpus() == 1) {
> + pr_info("PV spinlocks disabled\n");
> Why don't we need static_branch_disable(&virt_spin_lock_key) here?
Thanks for review.
I have a brief explanation in above comment area.
Boris also raised the same question in v4 and see my detailed explanation
in https://lkml.org/lkml/2019/10/6/39
>
> Also, as you're printing the exact reason for PV spinlocks disablement
> in other cases, I'd suggest separating "no host support" and "single
> CPU" cases.
Will do after reaching a consensus on your first question.
>
>> return;
>> + }
>>
>> if (kvm_para_has_hint(KVM_HINTS_REALTIME)) {
>> + pr_info("PV spinlocks disabled with KVM_HINTS_REALTIME hints.\n");
>> static_branch_disable(&virt_spin_lock_key);
>> return;
>> }
>>
>> - /* Don't use the pvqspinlock code if there is only 1 vCPU. */
>> - if (num_possible_cpus() == 1)
>> + if (nopvspin) {
>> + pr_info("PV spinlocks disabled forced by \"nopvspin\" parameter.\n");
> Nit: to make it sound better a comma is missing between 'disabled' and
> 'forced', or
>
> "PV spinlocks forcefully disabled by ..." if you prefer.
Will do.
Zhenzhong
Powered by blists - more mailing lists