Skip to content

Commit dafc17d

Browse files
committed
KVM: Add a comment explaining the directed yield pending interrupt logic
Add a comment to explain why KVM treats vCPUs with pending interrupts as in-kernel when a vCPU wants to yield to a vCPU that was preempted while running in kernel mode. Link: https://lore.kernel.org/r/20240110003938.490206-5-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 322d79f commit dafc17d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

virt/kvm/kvm_main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4090,6 +4090,13 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me, bool yield_to_kernel_mode)
40904090
continue;
40914091
if (kvm_vcpu_is_blocking(vcpu) && !vcpu_dy_runnable(vcpu))
40924092
continue;
4093+
4094+
/*
4095+
* Treat the target vCPU as being in-kernel if it has a
4096+
* pending interrupt, as the vCPU trying to yield may
4097+
* be spinning waiting on IPI delivery, i.e. the target
4098+
* vCPU is in-kernel for the purposes of directed yield.
4099+
*/
40934100
if (READ_ONCE(vcpu->preempted) && yield_to_kernel_mode &&
40944101
!kvm_arch_dy_has_pending_interrupt(vcpu) &&
40954102
!kvm_arch_vcpu_preempted_in_kernel(vcpu))

0 commit comments

Comments
 (0)