From: Paolo Bonzini Subject: Re: [PATCH] x86/kvm: Don't use pvqspinlock code if only 1 vCPU Date: Wed, 18 Jul 2018 13:51:18 +0200 Message-ID: <10b8511b-5488-1ea7-da45-3643e9e0a0b7@redhat.com> References: <1531864767-30648-1-git-send-email-longman@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joe Mario To: Waiman Long , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" Return-path: In-Reply-To: <1531864767-30648-1-git-send-email-longman@redhat.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 17/07/2018 23:59, Waiman Long wrote: > On a VM with only 1 vCPU, the locking fast path will always be > successful. In this case, there is no need to use the the PV qspinlock > code which has higher overhead on the unlock side than the native > qspinlock code. > > Signed-off-by: Waiman Long > --- > arch/x86/kernel/kvm.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > index 5b2300b..575c9a5 100644 > --- a/arch/x86/kernel/kvm.c > +++ b/arch/x86/kernel/kvm.c > @@ -748,6 +748,10 @@ void __init kvm_spinlock_init(void) > if (kvm_para_has_hint(KVM_HINTS_REALTIME)) > return; > > + /* Don't use the pvqspinlock code if there is only 1 vCPU. */ > + if (num_possible_cpus() == 1) > + return; > + > __pv_init_lock_hash(); > pv_lock_ops.queued_spin_lock_slowpath = __pv_queued_spin_lock_slowpath; > pv_lock_ops.queued_spin_unlock = PV_CALLEE_SAVE(__pv_queued_spin_unlock); > Queued, thanks. Paolo