From: Sean Christopherson <seanjc@google.com>
To: Luka Absandze <absandze@amazon.de>
Cc: David Woodhouse <dwmw2@infradead.org>,
Paolo Bonzini <pbonzini@redhat.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"Graf (AWS), Alexander" <graf@amazon.de>
Subject: Re: [RFC PATCH 0/2] KVM: x86/pmu: Let userspace disable SW accounting of emulated instructions
Date: Tue, 21 Jul 2026 10:49:11 -0700 [thread overview]
Message-ID: <al-xF6G4W6uEikao@google.com> (raw)
In-Reply-To: <al-szwXKRbdGYv49@dev-dsk-absandze-1c-663c31a8.eu-west-1.amazon.com>
On Tue, Jul 21, 2026, Luka Absandze wrote:
> On 2026-07-21 09:47, Sean Christopherson wrote:
> > Hmm, yeah, that'd be better than ignoring emulated instruction entirely, and
> > would give userspace far better control over how shoddy KVM's emulation is. Off
> > the cuff, the change would be fairly trivial too? E.g.
> >
> > diff --git arch/x86/kvm/pmu.c arch/x86/kvm/pmu.c
> > index 7f777049d328..c5f436c6f83f 100644
> > --- arch/x86/kvm/pmu.c
> > +++ arch/x86/kvm/pmu.c
> > @@ -1084,7 +1084,8 @@ static void kvm_pmu_incr_counter(struct kvm_pmc *pmc)
> > */
> > if (!kvm_vcpu_has_mediated_pmu(vcpu)) {
> > pmc->emulated_counter++;
> > - kvm_pmu_request_counter_reprogram(pmc);
> > + if (pmc->emulated_counter > pmu_something_something_tolerance)
> > + kvm_pmu_request_counter_reprogram(pmc);
> > return;
> > }
>
> I believe this is fine, but perhaps the tolerance itself could be a knob
Ya, I was envisioning a knob.
> with <0 meaning no reprogram?
Eh, I don't see a need to assign special meaning to <0. Make it a u32 (or u64),
and then a large value will provide the same behavior in practice, without needing
special handling in KVM.
> While the contention on this path will be much lower, we are still
> introducing more steal time, and the added accuracy is probably not worth
> even that for guests who really only care for the rate of change, rather than
> exact instruction counts.
prev parent reply other threads:[~2026-07-21 17:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 19:22 [RFC PATCH 0/2] KVM: x86/pmu: Let userspace disable SW accounting of emulated instructions Luka Absandze
2026-07-20 19:22 ` [RFC PATCH 1/2] KVM: x86/pmu: Add CAP to " Luka Absandze
2026-07-20 22:27 ` Sean Christopherson
2026-07-21 7:33 ` David Woodhouse
2026-07-21 16:53 ` Sean Christopherson
2026-07-21 19:43 ` David Woodhouse
2026-07-20 19:22 ` [RFC PATCH 2/2] KVM: Documentation: Document KVM_CAP_X86_DISABLE_PMU_SW_ACCOUNTING Luka Absandze
2026-07-21 7:32 ` [RFC PATCH 0/2] KVM: x86/pmu: Let userspace disable SW accounting of emulated instructions David Woodhouse
2026-07-21 16:47 ` Sean Christopherson
2026-07-21 16:55 ` David Woodhouse
2026-07-21 17:05 ` Sean Christopherson
2026-07-21 17:32 ` Absandze, Luka
2026-07-21 17:49 ` Sean Christopherson [this message]
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=al-xF6G4W6uEikao@google.com \
--to=seanjc@google.com \
--cc=absandze@amazon.de \
--cc=dwmw2@infradead.org \
--cc=graf@amazon.de \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox