[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190627222851.GC11506@sasha-vm>
Date: Thu, 27 Jun 2019 18:28:51 -0400
From: Sasha Levin <sashal@...nel.org>
To: Zhenzhong Duan <zhenzhong.duan@...cle.com>
Cc: linux-kernel@...r.kernel.org, tglx@...utronix.de, mingo@...nel.org,
bp@...en8.de, hpa@...or.com, boris.ostrovsky@...cle.com,
jgross@...e.com, sstabellini@...nel.org, peterz@...radead.org,
srinivas.eeda@...cle.com, Waiman Long <longman@...hat.com>,
"K. Y. Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
Ingo Molnar <mingo@...hat.com>, linux-hyperv@...r.kernel.org
Subject: Re: [PATCH v2 6/7] locking/spinlocks, paravirt, hyperv: Correct the
hv_nopvspin case
On Mon, Jun 24, 2019 at 08:02:58PM +0800, Zhenzhong Duan wrote:
>With the boot parameter "hv_nopvspin" specified a Hyperv guest should
>not make use of paravirt spinlocks, but behave as if running on bare
>metal. This is not true, however, as the qspinlock code will fall back
>to a test-and-set scheme when it is detecting a hypervisor.
>
>In order to avoid this disable the virt_spin_lock_key.
>
>Same change for XEN is already in Commit e6fd28eb3522
>("locking/spinlocks, paravirt, xen: Correct the xen_nopvspin case")
>
>Signed-off-by: Zhenzhong Duan <zhenzhong.duan@...cle.com>
>Cc: Waiman Long <longman@...hat.com>
>Cc: Peter Zijlstra (Intel) <peterz@...radead.org>
>Cc: "K. Y. Srinivasan" <kys@...rosoft.com>
>Cc: Haiyang Zhang <haiyangz@...rosoft.com>
>Cc: Stephen Hemminger <sthemmin@...rosoft.com>
>Cc: Sasha Levin <sashal@...nel.org>
>Cc: Thomas Gleixner <tglx@...utronix.de>
>Cc: Ingo Molnar <mingo@...hat.com>
>Cc: Borislav Petkov <bp@...en8.de>
>Cc: linux-hyperv@...r.kernel.org
>---
> arch/x86/hyperv/hv_spinlock.c | 3 +++
> 1 file changed, 3 insertions(+)
>
>diff --git a/arch/x86/hyperv/hv_spinlock.c b/arch/x86/hyperv/hv_spinlock.c
>index 07f21a0..d90b4b0 100644
>--- a/arch/x86/hyperv/hv_spinlock.c
>+++ b/arch/x86/hyperv/hv_spinlock.c
>@@ -64,6 +64,9 @@ __visible bool hv_vcpu_is_preempted(int vcpu)
>
> void __init hv_init_spinlocks(void)
> {
>+ if (unlikely(!hv_pvspin))
>+ static_branch_disable(&virt_spin_lock_key);
This should be combined in the conditional under it, which already
attempts to disable PV spinlocks, note how hv_pvspin is checked there.
hc_pvspin isn't the only reason we would disable PV spinlocks on hyperv.
Also, there's no need for the unlikely() here, it's only getting called
once...
--
Thanks,
Sasha
Powered by blists - more mailing lists