Skip to content

Commit 3553ae5

Browse files
Waiman-Longbonzini
authored andcommitted
x86/kvm: Don't use pvqspinlock code if only 1 vCPU
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 <longman@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 450917b commit 3553ae5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/x86/kernel/kvm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,10 @@ void __init kvm_spinlock_init(void)
748748
if (kvm_para_has_hint(KVM_HINTS_REALTIME))
749749
return;
750750

751+
/* Don't use the pvqspinlock code if there is only 1 vCPU. */
752+
if (num_possible_cpus() == 1)
753+
return;
754+
751755
__pv_init_lock_hash();
752756
pv_lock_ops.queued_spin_lock_slowpath = __pv_queued_spin_lock_slowpath;
753757
pv_lock_ops.queued_spin_unlock = PV_CALLEE_SAVE(__pv_queued_spin_unlock);

0 commit comments

Comments
 (0)