tools/libxc: Avoid cacheflush toolstack hypercalls on x86
PATCH 1/1 tools/libxc: Avoid cacheflush toolstack hypercalls on x86
XEN_DOMCTL_cacheflush hypercalls are (and will always be) -ENOSYS on x86, but xc_domain_cacheflush() is called often during domain build and migrate for correct behaviour on ARM.
Stub xc_domain_cacheflush() out on x86 to remove its pressure on the global domctl lock, and the hypercall overhead (which applies further pressure to the already heavily-contended TLB flush lock).
--- tools/libxc/xc_domain.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tools/libxc/xc_domain.c +16 -0
@@ -51,12 +51,28 @@ int xc_domain_create(xc_interface *xch,int xc_domain_cacheflush (xc_interface *xch,uint32_t domid,xen_pfn_t start_pfn,xen_pfn_t nr_pfns) { +#if defined (__i386__) || defined (__x86_64__) +/* +* The x86 architecture provides cache coherency guarantees which prevent +* the need for this hypercall. +* +* This call however is made frequently during domain build and migrate +* for the benefit of ARM, where cache flushes are needed. +* +* Stub it out here on x86 as domctls take the global domctl lock in Xen +* which is detrimental to concurrent toolstack operations on other +* domains. +*/ + errno =ENOSYS ; +return -1 ; +#else DECLARE_DOMCTL ; domctl.cmd = XEN_DOMCTL_cacheflush; domctl.domain = (domid_t )domid; domctl.u.cacheflush.start_pfn = start_pfn; domctl.u.cacheflush.nr_pfns = nr_pfns;return do_domctl (xch, &domctl); +#endif } int xc_domain_pause(xc_interface *xch,
Signature · 1 line
1.7.10.4
Quoted 8 lines · Andrew Cooper
XEN_DOMCTL_cacheflushhypercalls are (and will always be)-ENOSYSon x86, butxc_domain_cacheflush()is called often during domain build and migrate for correct behaviour on ARM.Stub
xc_domain_cacheflush()out on x86 to remove its pressure on the global domctl lock, and the hypercall overhead (which applies further pressure to the already heavily-contended TLB flush lock).
Quoted 7 lines
Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Tim Deegan <[email protected]>CC Ian Campbell <[email protected]>CC Ian Jackson <[email protected]>CC Wei Liu <[email protected]>
Although IMHO only the first paragraph of the comment is useful, the rest belongs in the commit log (where it already mostly is already).
Quoted 37 lines
--- tools/libxc/xc_domain.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)tools/libxc/xc_domain.c +16
-0@@ -51,12 +51,28 @@ int xc_domain_create(xc_interface *xch,int xc_domain_cacheflush (xc_interface *xch,uint32_t domid,xen_pfn_t start_pfn,xen_pfn_t nr_pfns) { +#if defined (__i386__) || defined (__x86_64__) +/* +* The x86 architecture provides cache coherency guarantees which prevent +* the need for this hypercall. +* +* This call however is made frequently during domain build and migrate +* for the benefit of ARM, where cache flushes are needed. +* +* Stub it out here on x86 as domctls take the global domctl lock in Xen +* which is detrimental to concurrent toolstack operations on other +* domains. +*/ + errno =ENOSYS ; +return -1 ; +#else DECLARE_DOMCTL ; domctl.cmd = XEN_DOMCTL_cacheflush; domctl.domain = (domid_t )domid; domctl.u.cacheflush.start_pfn = start_pfn; domctl.u.cacheflush.nr_pfns = nr_pfns;return do_domctl (xch, &domctl); +#endif } int xc_domain_pause(xc_interface *xch,
Quoted 16 lines · Ian Campbell
Quoted 8 lines · Andrew Cooper
XEN_DOMCTL_cacheflushhypercalls are (and will always be)-ENOSYSon x86, butxc_domain_cacheflush()is called often during domain build and migrate for correct behaviour on ARM.Stub
xc_domain_cacheflush()out on x86 to remove its pressure on the global domctl lock, and the hypercall overhead (which applies further pressure to the already heavily-contended TLB flush lock).Quoted 7 lines
Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Tim Deegan <[email protected]>CC Ian Campbell <[email protected]>CC Ian Jackson <[email protected]>CC Wei Liu <[email protected]>
Quoted 4 lines
Acked-by Ian Campbell <[email protected]>Although IMHO only the first paragraph of the comment is useful, the rest belongs in the commit log (where it already mostly is already).
I am happy for that to be fixed while committing, or I could resubmit?
~Andrew
Quoted 39 lines
Quoted 38 lines
--- tools/libxc/xc_domain.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)tools/libxc/xc_domain.c +16
-0@@ -51,12 +51,28 @@ int xc_domain_create(xc_interface *xch,int xc_domain_cacheflush (xc_interface *xch,uint32_t domid,xen_pfn_t start_pfn,xen_pfn_t nr_pfns) { +#if defined (__i386__) || defined (__x86_64__) +/* +* The x86 architecture provides cache coherency guarantees which prevent +* the need for this hypercall. +* +* This call however is made frequently during domain build and migrate +* for the benefit of ARM, where cache flushes are needed. +* +* Stub it out here on x86 as domctls take the global domctl lock in Xen +* which is detrimental to concurrent toolstack operations on other +* domains. +*/ + errno =ENOSYS ; +return -1 ; +#else DECLARE_DOMCTL ; domctl.cmd = XEN_DOMCTL_cacheflush; domctl.domain = (domid_t )domid; domctl.u.cacheflush.start_pfn = start_pfn; domctl.u.cacheflush.nr_pfns = nr_pfns;return do_domctl (xch, &domctl); +#endif } int xc_domain_pause(xc_interface *xch,
Quoted 17 lines · Andrew Cooper
Quoted 16 lines · Ian Campbell
Quoted 15 lines · Andrew Cooper
XEN_DOMCTL_cacheflushhypercalls are (and will always be)-ENOSYSon x86, butxc_domain_cacheflush()is called often during domain build and migrate for correct behaviour on ARM.Stub
xc_domain_cacheflush()out on x86 to remove its pressure on the global domctl lock, and the hypercall overhead (which applies further pressure to the already heavily-contended TLB flush lock).Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC Tim Deegan <[email protected]>CC Ian Campbell <[email protected]>CC Ian Jackson <[email protected]>CC Wei Liu <[email protected]>
Quoted 6 lines
Quoted 4 lines
Acked-by Ian Campbell <[email protected]>Although IMHO only the first paragraph of the comment is useful, the rest belongs in the commit log (where it already mostly is already).
I am happy for that to be fixed while committing, or I could resubmit?
If you think it's just a case of nuking the other two paras then I'll do it on commit, if you want to add some other words to the commit message best to resubmit.
Ian.
Quoted 43 lines
~Andrew
Quoted 39 lines
Quoted 38 lines
--- tools/libxc/xc_domain.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)tools/libxc/xc_domain.c +16
-0@@ -51,12 +51,28 @@ int xc_domain_create(xc_interface *xch,int xc_domain_cacheflush (xc_interface *xch,uint32_t domid,xen_pfn_t start_pfn,xen_pfn_t nr_pfns) { +#if defined (__i386__) || defined (__x86_64__) +/* +* The x86 architecture provides cache coherency guarantees which prevent +* the need for this hypercall. +* +* This call however is made frequently during domain build and migrate +* for the benefit of ARM, where cache flushes are needed. +* +* Stub it out here on x86 as domctls take the global domctl lock in Xen +* which is detrimental to concurrent toolstack operations on other +* domains. +*/ + errno =ENOSYS ; +return -1 ; +#else DECLARE_DOMCTL ; domctl.cmd = XEN_DOMCTL_cacheflush; domctl.domain = (domid_t )domid; domctl.u.cacheflush.start_pfn = start_pfn; domctl.u.cacheflush.nr_pfns = nr_pfns;return do_domctl (xch, &domctl); +#endif } int xc_domain_pause(xc_interface *xch,