Skip to content

Commit 9ee8363

Browse files
lrq-maxbonzini
authored andcommitted
KVM: x86: Yield to IPI target vCPU only if it is busy
When sending a call-function IPI-many to vCPUs, yield to the IPI target vCPU which is marked as preempted. but when emulating HLT, an idling vCPU will be voluntarily scheduled out and mark as preempted from the guest kernel perspective. yielding to idle vCPU is pointless and increase unnecessary vmexit, maybe miss the true preempted vCPU so yield to IPI target vCPU only if vCPU is busy and preempted Signed-off-by: Li RongQing <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 92e68cc commit 9ee8363

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kernel/kvm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ static void kvm_smp_send_call_func_ipi(const struct cpumask *mask)
624624

625625
/* Make sure other vCPUs get a chance to run if they need to. */
626626
for_each_cpu(cpu, mask) {
627-
if (vcpu_is_preempted(cpu)) {
627+
if (!idle_cpu(cpu) && vcpu_is_preempted(cpu)) {
628628
kvm_hypercall1(KVM_HC_SCHED_YIELD, per_cpu(x86_cpu_to_apicid, cpu));
629629
break;
630630
}

0 commit comments

Comments
 (0)