From: Sean Christopherson <seanjc@google.com>
To: Jing Zhang <jingzhangos@google.com>
Cc: Cannon Matthews <cannonmatthews@google.com>,
KVM <kvm@vger.kernel.org>, Paolo Bonzini <pbonzini@redhat.com>,
David Matlack <dmatlack@google.com>,
Peter Shier <pshier@google.com>, Oliver Upton <oupton@google.com>
Subject: Re: [PATCH] KVM: stats: add stats to detect if vcpu is currently halted
Date: Wed, 22 Sep 2021 16:39:14 +0000 [thread overview]
Message-ID: <YUtcMi3ft+my2JwF@google.com> (raw)
In-Reply-To: <CAAdAUtj-Y_MuaeqAHKonNTBDR=kjjmWP__Siqjv5=AxvZbe-Bw@mail.gmail.com>
On Fri, Aug 20, 2021, Jing Zhang wrote:
> Hi Sean,
>
> On Thu, Aug 19, 2021 at 3:37 PM Sean Christopherson <seanjc@google.com> wrote:
> >
> > On Wed, Aug 18, 2021, Cannon Matthews wrote:
> > > Since a guest has explictly asked for a vcpu to HLT, this is "useful work on
> > > behalf of the guest" even though the thread is "blocked" from running.
> > >
> > > This allows answering questions like, are we spending too much time waiting
> > > on mutexes, or long running kernel routines rather than running the vcpu in
> > > guest mode, or did the guest explictly tell us to not doing anything.
> > >
> > > So I would suggest keeping the "halt" part of the counters' name, and remove
> > > the "blocked" part rather than the other way around. We explicitly do not
> > > want to include non-halt blockages in this.
> >
> > But this patch does include non-halt blockages, which is why I brought up the
> > technically-wrong naming. Specifically, x86 reaches this path for any !RUNNABLE
> > vCPU state, e.g. if the vCPU is in WFS. Non-x86 usage appears to mostly call
> > this for halt-like behavior, but PPC looks like it has at least one path that's
> > not halt-like.
> >
> > I doubt anyone actually cares if the stat is a misnomer in some cases, but at the
> > same time I think there's opportunity for clean up here. E.g. halt polling if a
> > vCPU is in WFS or UNINITIALIZED is a waste of cycles. Ditto for the calls to
> > kvm_arch_vcpu_blocking() and kvm_arch_vcpu_unblocking() when halt polling is
> > successful, e.g. arm64 puts and reloads the vgic, which I assume is a complete
> > waste of cycles if the vCPU doesn't actually block. And kvm_arch_vcpu_block_finish()
> > can be dropped by moving the one line of code into s390, which can add its own
> > wrapper if necessary.
> >
> > So with a bit of massaging and a slight change in tracing behavior, I believe we
> > can isolate the actual wait/halt and avoid "halted" being technically-wrong, and
> > fix some inefficiencies at the same time.
> >
> > Jing, can you do a v2 of this patch and send it to me off-list? With luck, my
> > idea will work and I can fold your patch in, and if not we can always post v2
> > standalone in a few weeks.
Circling back to this with fresh eyes, limiting the state to "halted" would be
wrong. I still stand by my assertion that non-halt states such as WFS should not
go through halt polling, but the intent of the proposed stat is to differentiate
between not running a vCPU because of a guest action and not running a vCPU because
the host is not scheduling its task.
E.g. on x86, if a vCPU is put into WFS for an extended time, the vCPU will not be
run because of a guest action, not because of any host activity. But again, WFS
has very different meaning than "halt", which was the basis for my original
objection to the "halt_block" terminology.
One option would be to invert the stat, e.g. vcpu->stat.runnable, but that has the
downside of needed to be set somewhere outside of kvm_vcpu_block/halt(), and it
would likely be difficult to come up with a name that isn't confusing, e.g. the
vCPU would show up as "runnable" when mp_state!=RUNNABLE and it's not actively
blocking.
Back to bikeshedding the "halted" name, what about "blocking" or "waiting"? I.e.
switch from past tense to present tense to convey that the _vCPU_ is "actively"
blocking/waiting, as opposed to the vCPU being blocked by some host condition.
next prev parent reply other threads:[~2021-09-22 16:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-17 23:05 [PATCH] KVM: stats: add stats to detect if vcpu is currently halted Jing Zhang
2021-08-17 23:46 ` Sean Christopherson
2021-08-18 16:09 ` Jing Zhang
2021-08-18 16:57 ` Sean Christopherson
2021-08-18 17:01 ` Cannon Matthews
2021-08-19 18:09 ` Jing Zhang
2021-08-19 22:37 ` Sean Christopherson
2021-08-20 18:42 ` Jing Zhang
2021-09-22 16:39 ` Sean Christopherson [this message]
2021-09-22 16:41 ` 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=YUtcMi3ft+my2JwF@google.com \
--to=seanjc@google.com \
--cc=cannonmatthews@google.com \
--cc=dmatlack@google.com \
--cc=jingzhangos@google.com \
--cc=kvm@vger.kernel.org \
--cc=oupton@google.com \
--cc=pbonzini@redhat.com \
--cc=pshier@google.com \
/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.