KVM: x86: Skip directed-yield targets that are not scheduled out
Quoted 6 lines · Sean Christopherson
Quoted 3 lines · On Sun, Feb 15, 2026, [email protected] wrote:
From: zhanghao <[email protected]>
[原邮件内容]
[回复内容]
Hi Sean,
Thank you for the detailed review. I'd like to provide additional context on the two new checks in kvm_vcpu_on_spin() and request your feedback on the implementation.
## Code in Question
/*
* kvm_vcpu_wake_up() can race with kvm_sched_in() and leave @ready
* true for a running vCPU. Filter out vCPUs that are not currently
* scheduled out to avoid futile directed-yield attempts. */
if (!READ_ONCE(vcpu->scheduled_out))
continue;
/*
* Additionally, skip vCPUs that are currently in guest mode.
* A vCPU in IN_GUEST_MODE cannot be yielded to until it exits
* to host mode.
*/
if (READ_ONCE(vcpu->mode) == IN_GUEST_MODE)
continue;
## Rationale for Two Checks
[详细解释...]
Please let me know if you'd like any changes or have concerns about the approach.
Best regards,
zhanghao