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

[Xen-changelog] [xen staging] x86/pv: Fix `global-pages` to match the documentation



commit b041709c369b36cb17a019a196fba773ec7e77bd
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Mon Dec 16 13:58:45 2019 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Mon Dec 16 16:04:10 2019 +0000

    x86/pv: Fix `global-pages` to match the documentation
    
    c/s 5de961d9c09 "x86: do not enable global pages when virtualized on AMD or
    Hygon hardware" in fact does.  Fix the calculation in pge_init().
    
    While fixing this, adjust the command line documenation, first to use the
    newer style, and to expand the description to discuss cases where the option
    might be useful to use, but Xen can't account for by default.
    
    Fixes: 5de961d9c09 ('x86: do not enable global pages when virtualized on 
AMD or Hygon hardware')
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 docs/misc/xen-command-line.pandoc | 24 +++++++++++++++---------
 xen/arch/x86/pv/domain.c          |  4 ++--
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/docs/misc/xen-command-line.pandoc 
b/docs/misc/xen-command-line.pandoc
index 7a1be84ca9..cb54a000fc 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -1087,18 +1087,24 @@ value settable via Xen tools.
 
 Dom0 is using this value for sizing its maptrack table.
 
-### global-pages (x86)
-> `= <boolean>`
+### global-pages
+    = <boolean>
+
+    Applicability: x86
+    Default: true unless running virtualized on AMD or Hygon hardware
 
-> Default: `true` unless running virtualized on AMD or Hygon hardware
+Control whether to use global pages for PV guests, and thus the need to
+perform TLB flushes by writing to CR4.  This is a performance trade-off.
 
-Set whether the PGE bit in CR4 will be enabled for PV guests. This controls the
-usage of global pages, and thus the need to perform tlb flushes by writing to
-CR4.
+AMD SVM does not support selective trapping of CR4 writes, which means that a
+global TLB flush (two CR4 writes) takes two VMExits, and massively outweigh
+the benefit of using global pages to begin with.  This case is easy for Xen to
+spot, and is accounted for in the default setting.
 
-Note it's disabled by default when running virtualized on AMD or Hygon hardware
-since AMD SVM doesn't support selective trapping of CR4, so global pages are
-not enabled in order to reduce the overhead of TLB flushes.
+Other cases where this option might be a benefit is on VT-x hardware when
+selective CR4 writes are not supported/enabled by the hypervisor, or in any
+virtualised case using shadow paging.  These are not easy for Xen to spot, so
+are not accounted for in the default setting.
 
 ### guest_loglvl
 > `= <level>[/<rate-limited level>]` where level is `none | error | warning | 
 > info | debug | all`
diff --git a/xen/arch/x86/pv/domain.c b/xen/arch/x86/pv/domain.c
index e6e1c51548..ed5111fc47 100644
--- a/xen/arch/x86/pv/domain.c
+++ b/xen/arch/x86/pv/domain.c
@@ -125,8 +125,8 @@ static int __init pge_init(void)
 {
     if ( opt_global_pages == -1 )
         opt_global_pages = !cpu_has_hypervisor ||
-                           (boot_cpu_data.x86_vendor &
-                            (X86_VENDOR_AMD | X86_VENDOR_HYGON));
+                           !(boot_cpu_data.x86_vendor &
+                             (X86_VENDOR_AMD | X86_VENDOR_HYGON));
 
     return 0;
 }
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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