[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 2/2] x86/pvshim: do not enable global pages in shim mode


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 29 Nov 2019 15:36:46 +0100
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@xxxxxxxxxx; spf=Pass smtp.mailfrom=roger.pau@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 29 Nov 2019 14:37:00 +0000
  • Ironport-sdr: wUfGZT4SLiK4co4H9AajT6g+fOpnBl4bOSjT4SOeWH1tdy5NWoBoN3hibh0rT2ZtCnokZeFWuz kG0nSMSIgVjoLvVbXnXqHai096PKSDgw6f9Q2tuIk8JVFzK2cOZcaepLfGaSwe+low6uS7fVFn XhM5HYu8xLwT8Gdi9eJBQjLkUUOQ8myC3A2B6FX89NtzuNsUAqgnD+B4rIK8nqSBLmU6rfzJuU RyA8lyUiFfFj3II8mVcT6yV7d/F/7ezljo/qJKI04139+A+8VFLsAbMrkOwbrz7jHSIsn7N26B GAE=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, Nov 29, 2019 at 12:12:51PM +0000, Andrew Cooper wrote:
> On 29/11/2019 12:09, Jan Beulich wrote:
> > On 25.11.2019 18:22, Roger Pau Monne wrote:
> >> When using global pages a full tlb flush can only be performed by
> >> toggling the PGE bit in CR4, which is usually quite expensive in terms
> >> of performance when running virtualized. This is specially relevant on
> >> AMD hardware, which doesn't have the ability to do selective CR4
> >> trapping, but can also be relevant on Intel if the underlying
> >> hypervisor also traps on accesses to the PGE CR4 bit.
> >>
> >> In order to avoid this performance penalty, do not use global pages
> >> when running in shim mode. Note this is done when running on both
> >> Intel or AMD hardware, since older versions of Xen capable of running
> >> the shim don't make use of Intel selective CR4 trapping feature and
> >> will vmexit on every access to CR4.
> > So here you say you do this uniformly because of older Xen.
> > What about newer Xen? Is this still a win (or at least not a
> > loss) there? Independent of underlying hardware?

So on Intel hw that don't trap CR4 PGE accesses disabling PGE seems to
make performance slightly worse when doing a `make -j8 xen` on a 8 vCPU
pv-shim guest:

CR4 PGE enabled:
real    2m40.889s
real    2m41.700s
real    2m40.453s

CR4 PGE disabled:
real    2m43.197s
real    2m41.940s
real    2m42.727s

> > In case of
> > any kind of doubt I think this would want to be command line
> > controllable.
> 
> Older Xen has VMExits for all CR4.PGE flips.
> 
> Newer Xen (since 4.10? iirc) on Intel hardware (with HAP) arranged for
> CR4.PGE flips not to vmexit.
> 
> There is no ability to cause CR4.PGE flips to not vmexit on AMD, other
> than to give the guest full control of CR4 which is a BadThing(tm).
> 
> I agree that this wants a command line control, but it wants to be
> enabled by default any time we find ourselves nested on AMD hardware,
> not just in shim.

Only on AMD hardware? Newer versions of Xen don't trap CR4 PGE writes,
but what about other hypervisors?

I think it would be better to avoid using PGE when the hypervisor
CPUID bit is set, regardless of whether the hardware is AMD or not.
The performance penalty doesn't seem that bad, taking into account
that using PGE when CR4 is trapped is much worse. Alternatively we
could try to detect how slow a flush from CR4 is and act accordingly,
but that seems tricky.

I can add a command line option to force or prevent the usage of PGE.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.