Skip to content

Commit ec756e4

Browse files
Wanpeng Libonzini
authored andcommitted
x86/kvm: Don't use pv tlb/ipi/sched_yield if on 1 vCPU
Inspired by commit 3553ae5 (x86/kvm: Don't use pvqspinlock code if only 1 vCPU), on a VM with only 1 vCPU, there is no need to enable pv tlb/ipi/sched_yield and we can save the memory for __pv_cpu_mask. Signed-off-by: Wanpeng Li <wanpengli@tencent.com> Message-Id: <1645171838-2855-1-git-send-email-wanpengli@tencent.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent ba1f77c commit ec756e4

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

arch/x86/kernel/kvm.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,19 +462,22 @@ static bool pv_tlb_flush_supported(void)
462462
{
463463
return (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
464464
!kvm_para_has_hint(KVM_HINTS_REALTIME) &&
465-
kvm_para_has_feature(KVM_FEATURE_STEAL_TIME));
465+
kvm_para_has_feature(KVM_FEATURE_STEAL_TIME) &&
466+
(num_possible_cpus() != 1));
466467
}
467468

468469
static bool pv_ipi_supported(void)
469470
{
470-
return kvm_para_has_feature(KVM_FEATURE_PV_SEND_IPI);
471+
return (kvm_para_has_feature(KVM_FEATURE_PV_SEND_IPI) &&
472+
(num_possible_cpus() != 1));
471473
}
472474

473475
static bool pv_sched_yield_supported(void)
474476
{
475477
return (kvm_para_has_feature(KVM_FEATURE_PV_SCHED_YIELD) &&
476478
!kvm_para_has_hint(KVM_HINTS_REALTIME) &&
477-
kvm_para_has_feature(KVM_FEATURE_STEAL_TIME));
479+
kvm_para_has_feature(KVM_FEATURE_STEAL_TIME) &&
480+
(num_possible_cpus() != 1));
478481
}
479482

480483
#define KVM_IPI_CLUSTER_SIZE (2 * BITS_PER_LONG)

0 commit comments

Comments
 (0)