public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Bernhard Kauer <bk@alpico.io>
To: Sean Christopherson <seanjc@google.com>
Cc: Bernhard Kauer <bk@alpico.io>,
	kvm@vger.kernel.org, Chao Gao <chao.gao@intel.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v2] KVM: x86: Drop the kvm_has_noapic_vcpu optimization
Date: Tue, 10 Dec 2024 09:16:37 +0100	[thread overview]
Message-ID: <Z1f45XzpgDMC2cvI@mias.mediconcil.de> (raw)
In-Reply-To: <Z1ecILHBlpkiAThl@google.com>

On Mon, Dec 09, 2024 at 05:40:48PM -0800, Sean Christopherson wrote:
> On Mon, Dec 09, 2024, Sean Christopherson wrote:
> > On Mon, Oct 21, 2024, Bernhard Kauer wrote:
> > > It used a static key to avoid loading the lapic pointer from
> > > the vcpu->arch structure.  However, in the common case the load
> > > is from a hot cacheline and the CPU should be able to perfectly
> > > predict it. Thus there is no upside of this premature optimization.
> > > 
> > > The downside is that code patching including an IPI to all CPUs
> > > is required whenever the first VM without an lapic is created or
> > > the last is destroyed.
> > >
> > I'm on the fence, slightly leaning towards removing all three of these static keys.

Thanks for continuing this work.


> > With a single vCPU pinned to a single pCPU, the average latency for a CPUID exit
> > goes from 1018 => 1027 cycles, plus or minus a few.  With 8 vCPUs, no pinning
> > (mostly laziness), the average latency goes from 1034 => 1053.

Are these kind of benchmarks tracked somewhere automatically?  With it one
could systematically optimize for faster exits.


> > On the other hand, we lose gobs and gobs of cycles with far less thought.  E.g.
> > with mitigations on, the latency for a single vCPU jumps all the way to 1600+ cycles.

In the end it is a tradeoff to be made.  The cost for switching between the
modes is more than a hundred microsecond unexpected latency.  On the other
hande one saves 1-2% per exit but has a larger code-base.



  reply	other threads:[~2024-12-10  8:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-21 10:22 [PATCH v2] KVM: x86: Drop the kvm_has_noapic_vcpu optimization Bernhard Kauer
2024-12-10  1:22 ` Sean Christopherson
2024-12-10  1:40   ` Sean Christopherson
2024-12-10  8:16     ` Bernhard Kauer [this message]
2024-12-11 17:16       ` Sean Christopherson
2024-12-12 10:19         ` Bernhard Kauer
2024-12-12 15:16           ` 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=Z1f45XzpgDMC2cvI@mias.mediconcil.de \
    --to=bk@alpico.io \
    --cc=chao.gao@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox