From: Sean Christopherson <seanjc@google.com>
To: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>
Cc: Mathias Krause <minipli@grsecurity.net>, Greg KH <greg@kroah.com>,
kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v4 0/6] KVM: MMU: performance tweaks for heavy CR0.WP users
Date: Fri, 14 Apr 2023 13:17:28 -0700 [thread overview]
Message-ID: <ZDm02GVx0/tiIoiM@google.com> (raw)
In-Reply-To: <20230414200941.GA6776@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>
On Fri, Apr 14, 2023, Jeremi Piotrowski wrote:
> On Fri, Apr 14, 2023 at 09:49:28AM -0700, Sean Christopherson wrote:
> > +Jeremi
> >
>
> Adding myself :)
/facepalm
This isn't some mundane detail, Michael!!!
> > On Fri, Apr 14, 2023, Mathias Krause wrote:
>
> ...
>
> > > OTOH, the backports give nice speed-ups, ranging from ~2.2 times faster
> > > for pure EPT (legacy) MMU setups up to 18(!!!) times faster for TDP MMU
> > > on v5.10.
> >
> > Anyone that's enabling the TDP MMU on v5.10 is on their own, we didn't enable the
> > TDP MMU by default until v5.14 for very good reasons.
> >
> > > I backported the whole series down to v5.10 but left out the CR0.WP
> > > guest owning patch+fix for v5.4 as the code base is too different to get
> > > all the nuances right, as Sean already hinted. However, even this
> > > limited backport provides a big performance fix for our use case!
> >
> > As a compromise of sorts, I propose that we disable the TDP MMU by default on v5.15,
> > and backport these fixes to v6.1. v5.15 and earlier won't get "ludicrous speed", but
> > I think that's perfectly acceptable since KVM has had the suboptimal behavior
> > literally since EPT/NPT support was first added.
> >
>
> Disabling TDP MMU for v5.15, and backporting things to v6.1 works for me.
>
> > I'm comfortable backporting to v6.1 as that is recent enough, and there weren't
> > substantial MMU changes between v6.1 and v6.3 in this area. I.e. I have a decent
> > level of confidence that we aren't overlooking some subtle dependency.
> >
> > For v5.15, I am less confident in the safety of a backport, and more importantly,
> > I think we should disable the TDP MMU by default to mitigate the underlying flaw
> > that makes the 18x speedup possible. That flaw is that KVM can end up freeing and
> > rebuilding TDP MMU roots every time CR0.WP is toggled or a vCPU transitions to/from
> > SMM.
> >
>
> The interesting thing here is that these CR0.WP fixes seem to improve things
> with legacy MMU as well, and legacy MMU is not affected/touched by [3].
Yep, that's totally expected. The final patch in this series allows KVM to elide
VM-Exits when the guest toggles CR0.WP (but only on Intel hardware). Avoiding
VM-Exit entirely is a big performance win when the guest is constantly toggling
CR0.WP, e.g. each exit is roughly 1500 cycles, versus probalby something like ~50
for a native write to CR0.WP.
> So I think you can consider Mathias' ask independent of disabling TDP MMU. On the one
> hand: there is no regression here. On the other: the gain is big and seems important
> to him.
Ya, that's the compromise I am proposing. Give v6.1 the full tune-up, but only
do the super safe change for v5.15.
next prev parent reply other threads:[~2023-04-14 20:17 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 1:37 [PATCH v4 0/6] KVM: MMU: performance tweaks for heavy CR0.WP users Mathias Krause
2023-03-22 1:37 ` [PATCH v4 1/6] KVM: x86/mmu: Avoid indirect call for get_cr3 Mathias Krause
2023-03-22 1:37 ` [PATCH v4 2/6] KVM: x86: Do not unload MMU roots when only toggling CR0.WP with TDP enabled Mathias Krause
2023-05-07 7:32 ` Robert Hoo
2023-05-08 9:30 ` Mathias Krause
2023-05-09 1:04 ` Robert Hoo
2023-03-22 1:37 ` [PATCH v4 3/6] KVM: x86: Ignore CR0.WP toggles in non-paging mode Mathias Krause
2023-03-22 1:37 ` [PATCH v4 4/6] KVM: x86: Make use of kvm_read_cr*_bits() when testing bits Mathias Krause
2023-03-22 1:37 ` [PATCH v4 5/6] KVM: x86/mmu: Fix comment typo Mathias Krause
2023-03-22 1:37 ` [PATCH v4 6/6] KVM: VMX: Make CR0.WP a guest owned bit Mathias Krause
2023-03-27 8:33 ` Xiaoyao Li
2023-03-27 8:37 ` Mathias Krause
2023-03-27 13:48 ` Xiaoyao Li
2023-03-30 8:45 ` Mathias Krause
2023-03-30 17:12 ` Sean Christopherson
2023-03-30 20:15 ` Mathias Krause
2023-03-30 20:30 ` Mathias Krause
2023-03-30 20:36 ` Sean Christopherson
2023-03-30 20:33 ` Sean Christopherson
2023-03-30 20:55 ` Mathias Krause
2023-03-31 14:18 ` Mathias Krause
2023-03-22 7:41 ` [PATCH v4 0/6] KVM: MMU: performance tweaks for heavy CR0.WP users Mathias Krause
2023-03-23 22:50 ` Sean Christopherson
2023-03-25 11:39 ` Mathias Krause
2023-03-25 12:25 ` Greg KH
2023-04-06 2:25 ` Sean Christopherson
2023-04-06 13:22 ` Mathias Krause
2023-04-14 9:29 ` Mathias Krause
2023-04-14 16:49 ` Sean Christopherson
2023-04-14 20:09 ` Jeremi Piotrowski
2023-04-14 20:17 ` Sean Christopherson [this message]
2023-05-02 17:38 ` Jeremi Piotrowski
2023-05-08 9:19 ` Mathias Krause
2023-05-08 15:57 ` Mathias Krause
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=ZDm02GVx0/tiIoiM@google.com \
--to=seanjc@google.com \
--cc=greg@kroah.com \
--cc=jpiotrowski@linux.microsoft.com \
--cc=kvm@vger.kernel.org \
--cc=minipli@grsecurity.net \
--cc=pbonzini@redhat.com \
--cc=stable@vger.kernel.org \
/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.