Skip to content

Commit 1280c8a

Browse files
Wanpeng Ligregkh
Wanpeng Li
authored andcommitted
x86/kvm: Don't use pv tlb/ipi/sched_yield if on 1 vCPU
[ Upstream commit ec756e4 ] 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 <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent ee22082 commit 1280c8a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

arch/x86/kernel/kvm.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,19 +457,22 @@ static bool pv_tlb_flush_supported(void)
457457
{
458458
return (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) &&
459459
!kvm_para_has_hint(KVM_HINTS_REALTIME) &&
460-
kvm_para_has_feature(KVM_FEATURE_STEAL_TIME));
460+
kvm_para_has_feature(KVM_FEATURE_STEAL_TIME) &&
461+
(num_possible_cpus() != 1));
461462
}
462463

463464
static bool pv_ipi_supported(void)
464465
{
465-
return kvm_para_has_feature(KVM_FEATURE_PV_SEND_IPI);
466+
return (kvm_para_has_feature(KVM_FEATURE_PV_SEND_IPI) &&
467+
(num_possible_cpus() != 1));
466468
}
467469

468470
static bool pv_sched_yield_supported(void)
469471
{
470472
return (kvm_para_has_feature(KVM_FEATURE_PV_SCHED_YIELD) &&
471473
!kvm_para_has_hint(KVM_HINTS_REALTIME) &&
472-
kvm_para_has_feature(KVM_FEATURE_STEAL_TIME));
474+
kvm_para_has_feature(KVM_FEATURE_STEAL_TIME) &&
475+
(num_possible_cpus() != 1));
473476
}
474477

475478
#define KVM_IPI_CLUSTER_SIZE (2 * BITS_PER_LONG)

0 commit comments

Comments
 (0)