From: Sean Christopherson <seanjc@google.com>
To: 76824143@qq.com
Cc: pbonzini@redhat.com, kvm@vger.kernel.org,
zhanghao <zhanghao1@kylinos.cn>
Subject: Re: [PATCH 1/3] KVM: x86: Enhance kvm_vcpu_eligible_for_directed_yield to detect golden targets
Date: Tue, 17 Feb 2026 07:37:03 -0800 [thread overview]
Message-ID: <aZSLHyMp7WQ_HxeD@google.com> (raw)
In-Reply-To: <tencent_606610DBCF4CC9C810B0694110E12E135C05@qq.com>
On Sun, Feb 15, 2026, 76824143@qq.com wrote:
> From: zhanghao <zhanghao1@kylinos.cn>
>
> Detect "golden targets" - vCPUs that are preempted and ready.
> These are ideal yield targets as they can be immediately scheduled.
>
> This check reduces unnecessary yield attempts to vCPUs that are
> unlikely to benefit from directed yield.
>
> Signed-off-by: zhanghao <zhanghao1@kylinos.cn>
> ---
> virt/kvm/kvm_main.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 61dca8d37abc..476ecdb18bdd 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -3927,6 +3927,9 @@ static bool kvm_vcpu_eligible_for_directed_yield(struct kvm_vcpu *vcpu)
> #ifdef CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT
> bool eligible;
>
> + if (READ_ONCE(vcpu->preempted) && READ_ONCE(vcpu->mode) == IN_GUEST_MODE)
This is nonsensical. It should be impossible for a vCPU to be preempted while
IN_GUEST_MODE is true. Even if a host IRQ arrives while the guest is active,
KVM should set vcpu->mode back to OUTSIDE_GUEST_MODE prior to servicing the IRQ.
Even more confusing, the next patch explicitly rejects IN_GUEST_MODE vCPUs from
kvm_vcpu_on_spin().
> + return true;
> +
> eligible = !vcpu->spin_loop.in_spin_loop ||
> vcpu->spin_loop.dy_eligible;
>
> --
> 2.39.2
>
next prev parent reply other threads:[~2026-02-17 15:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260215140402.24659-1-76824143@qq.com>
2026-02-15 14:04 ` [PATCH 1/3] KVM: x86: Enhance kvm_vcpu_eligible_for_directed_yield to detect golden targets 76824143
2026-02-17 15:37 ` Sean Christopherson [this message]
2026-02-15 14:04 ` [PATCH 2/3] KVM: x86: Skip IN_GUEST_MODE vCPUs in kvm_vcpu_on_spin main loop 76824143
2026-02-17 15:41 ` Sean Christopherson
2026-03-12 5:57 ` zhanghao
2026-03-13 1:02 ` Sean Christopherson
2026-03-19 8:40 ` zhanghao
2026-02-15 14:04 ` [PATCH 3/3] KVM: x86: Use dynamic try count based on vCPU count 76824143
2026-02-17 16:21 ` Sean Christopherson
2026-03-12 6:24 ` zhanghao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aZSLHyMp7WQ_HxeD@google.com \
--to=seanjc@google.com \
--cc=76824143@qq.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=zhanghao1@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.