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: Alexander Graf <graf@amazon.de>, kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: drop the kvm_has_noapic_vcpu optimization
Date: Fri, 15 Nov 2024 10:12:02 +0100	[thread overview]
Message-ID: <ZzcQYoExgpAzItdp@mias.mediconcil.de> (raw)
In-Reply-To: <ZyTqZk88JbE3EcTk@google.com>

On Fri, Nov 01, 2024 at 07:49:10AM -0700, Sean Christopherson wrote:
> On Fri, Nov 01, 2024, Bernhard Kauer wrote:
> > On Thu, Oct 31, 2024 at 04:29:52PM -0700, Sean Christopherson wrote:
> > > With a userspace APIC, the roundtrip to userspace to emulate the EOI is measured
> > > in tens of thousands of cycles.  IIRC, last I played around with userspace exits
> > > the average turnaround time was ~50k cycles.
> > 
> > 
> > That sound a lot so I did some quick benchmarking.  An exit is around 1400
> > TSC cycles on my AMD laptop, instruction emulation takes 1200 and going
> > to user-level needs at least 6200.  Not terribly slow but still room for
> > optimizations.
> 
> Ah, I suspect my recollection of ~50k cycles is from measuring all exits to
> userspace, i.e. included the reaaaaly slow paths.

I finally found the reason for the slow user-level roundtrip on my Zen3+
machine.

Disabling SRSO with spec_rstack_overflow=off improves the user-level part
by 3x.  The exit as well as the instruction emulation overhead is down by 40%.

Thus without SRSO a roundtrip to user-level needs roughly 2000 cycles.


                        SRSO=off        default         factor
INSTR   CPUID           1008            1394            1.4x
        RDMSR           1072            1550            1.4x
MMIO    APIC            1666            2609            1.6x
        IOAPIC          1783            2800            1.6x
        HPET            3626            9426            2.6x
PIO     PIC             1250            1804            1.4x
        UART            2837            8011            2.8x


      reply	other threads:[~2024-11-15  9:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18 10:08 [PATCH] KVM: drop the kvm_has_noapic_vcpu optimization Bernhard Kauer
2024-10-21  7:43 ` Chao Gao
2024-10-22 17:32 ` Sean Christopherson
2024-10-22 19:08   ` Bernhard Kauer
2024-10-31 16:24     ` Sean Christopherson
2024-10-31 20:08       ` Bernhard Kauer
2024-10-31 23:29         ` Sean Christopherson
2024-11-01  8:55           ` Bernhard Kauer
2024-11-01 14:49             ` Sean Christopherson
2024-11-15  9:12               ` Bernhard Kauer [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=ZzcQYoExgpAzItdp@mias.mediconcil.de \
    --to=bk@alpico.io \
    --cc=graf@amazon.de \
    --cc=kvm@vger.kernel.org \
    --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