From: Sean Christopherson <seanjc@google.com>
To: zhanghao <76824143@qq.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
zhanghao <zhanghao1@kylinos.cn>,
Wanpeng Li <kernellwp@gmail.com>
Subject: Re: [PATCH] KVM: Drop kvm_vcpu.ready to squash race where "ready" can get stuck "true"
Date: Tue, 14 Apr 2026 06:44:02 -0700 [thread overview]
Message-ID: <ad5BsDdZ9FGpMIhH@google.com> (raw)
In-Reply-To: <tencent_510B7687999B510DE0D00238024766980C06@qq.com>
On Tue, Apr 14, 2026, zhanghao wrote:
> On Thu, Apr 09, 2026, Sean Christopherson wrote:
> > Drop kvm_vcpu.ready and instead detect the case where a recently awakened
> > vCPU is runnable but not yet scheduled in by explicitly, manually checking
> > for a target vCPU that is (a) scheduled out, (b) wants to run, (c) is
> > marked as blocking in its stat, but (d) not actually flagged as blocking.
> > I.e. treat a runnable vCPU that's in the blocking sequence but not truly
> > blocking as a candidate for directed yield.
> >
> > Keying off vcpu->stat.generic.blocking will yield some number of false
> > positives, e.g. if the vCPU is preempted _before_ blocking, but the rate of
> > false positives should be roughly the same as the existing approach, as
> > kvm_sched_out() would previously mark the vCPU as ready when it's scheduled
> > out and runnable.
> >
> > Eliminating the write to vcpu->ready in kvm_vcpu_wake_up() fixes a race
> > where vcpu->ready could be set *after* the target vCPU is scheduled in,
> > e.g. if the task waking the target vCPU is preempted (or otherwise delayed)
> > after waking the vCPU, but before setting vcpu->ready. Hitting the race
> > leads to a very degraded state as KVM will constantly attempt to schedule
> > in a vCPU that is already running.
...
> kvm_vcpu.ready still exists in struct kvm_vcpu, but there are no remaining
> users after this patch, so it looks like a leftover cleanup item.
Gah, I intended to remove kvm_vcpu.ready, not sure how I didn't. Thanks!
next prev parent reply other threads:[~2026-04-14 13:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 21:33 [PATCH] KVM: Drop kvm_vcpu.ready to squash race where "ready" can get stuck "true" Sean Christopherson
2026-04-14 9:09 ` zhanghao
2026-04-14 13:44 ` Sean Christopherson [this message]
2026-04-14 16:06 ` Paolo Bonzini
2026-04-14 22:38 ` Sean Christopherson
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=ad5BsDdZ9FGpMIhH@google.com \
--to=seanjc@google.com \
--cc=76824143@qq.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox