tools/libxc: Avoid hypercalls for cacheflush on x86
PATCH 1/1 tools/libxc: Avoid hypercalls for cacheflush on x86
XEN_DOMCTL_cacheflush hypercalls are -ENOSYS on x86. As domain creation/migration is already very hypercall-heavy, avoid making extra redundant hypercalls
---
Discovered when running valgrind against XenServer trunk, which is now 4.4 based.
--- tools/libxc/xc_domain.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/libxc/xc_domain.c +6 -0
@@ -51,12 +51,18 @@ 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__) +/* This is not implemented or needed for x86. Avoid repeatedly going to +* Xen to find -ENOSYS. */ +return -ENOSYS ; +#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 26 lines · Andrew Cooper
XEN_DOMCTL_cacheflushhypercalls are-ENOSYSon x86. As domain creation/migration is already very hypercall-heavy, avoid making extra redundant hypercallsSigned-off-by Andrew Cooper <[email protected]>CC Ian Campbell <[email protected]>CC Ian Jackson <[email protected]>---
Discovered when running valgrind against XenServer trunk, which is now 4.4 based.
--- tools/libxc/xc_domain.c | 6 ++++++ 1 file changed, 6 insertions(+)tools/libxc/xc_domain.c +2
-0@@ -51,12 +51,18 @@ 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__) +/* This is not implemented or needed for x86. Avoid repeatedly going to
tools/libxc/xc_domain.c int xc_domain_create(xc_interface *xch, · line 65
Quoted 10 lines
tools/libxc/xc_domain.c +4
-0+* Xen to find -ENOSYS. */ +return -ENOSYS ; +#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
Rather than icky #ifdef's I suggest caching the result of any -ENOSYS return value.
David
Andrew Cooper writes ("[PATCH] tools/libxc: Avoid hypercalls for cacheflush on x86"):
Quoted 3 lines
XEN_DOMCTL_cacheflushhypercalls are-ENOSYSon x86. As domain creation/migration is already very hypercall-heavy, avoid making extra redundant hypercalls
Surely this should be done by moving the relevant code to an arm-specific file, not by #ifdeffery.
Thanks,
Ian.
Quoted 7 lines · Ian Jackson
Andrew Cooper writes ("[PATCH]
tools/libxc: Avoid hypercalls for cacheflush on x86"):Quoted 3 lines
XEN_DOMCTL_cacheflushhypercalls are-ENOSYSon x86. As domain creation/migration is already very hypercall-heavy, avoid making extra redundant hypercallsSurely this should be done by moving the relevant code to an arm-specific file, not by #ifdeffery.
I think it is very debatable that sort-circuiting a single ENOSYS hypercall in the tools is even worth it at all. "very hypercall heavy" doesn't cut it as a rationale IMHO. Unless an actual demonstrable improvement is seen, perhaps over a larger series removing a large number of so called redundant calls, it's just an additional source of confusion (due to gating at multiple levels) as far as I'm concerned.
Ian.
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Ian Jackson
Andrew Cooper writes ("[PATCH]
tools/libxc: Avoid hypercalls for cacheflush on x86"):Quoted 3 lines
XEN_DOMCTL_cacheflushhypercalls are-ENOSYSon x86. As domain creation/migration is already very hypercall-heavy, avoid making extra redundant hypercallsSurely this should be done by moving the relevant code to an arm-specific file, not by #ifdeffery.
Quoted 9 lines
I think it is very debatable that sort-circuiting a single ENOSYS hypercall in the tools is even worth it at all. "very hypercall heavy" doesn't cut it as a rationale IMHO. Unless an actual demonstrable improvement is seen, perhaps over a larger series removing a large number of so called redundant calls, it's just an additional source of confusion (due to gating at multiple levels) as far as I'm concerned.
Ian.
For booting a single guest, noone will notice. Booting 10 or more at a time however is very different.
XenServer, along with all other virtualisation platforms live in a world where "Net time to boot $N guests" (where N is measured in hundreds) is an important quantity, and needless overhead from things like this cause dom0 needless load that it would rather do without.
I should say that I have not done any performance metrics on this - as noted in the patch I stumbled upon it with valgrind.
~Andrew
Quoted 18 lines · Andrew Cooper
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Ian Jackson
Andrew Cooper writes ("[PATCH]
tools/libxc: Avoid hypercalls for cacheflush on x86"):Quoted 3 lines
XEN_DOMCTL_cacheflushhypercalls are-ENOSYSon x86. As domain creation/migration is already very hypercall-heavy, avoid making extra redundant hypercallsSurely this should be done by moving the relevant code to an arm-specific file, not by #ifdeffery.
Quoted 9 lines
I think it is very debatable that sort-circuiting a single ENOSYS hypercall in the tools is even worth it at all. "very hypercall heavy" doesn't cut it as a rationale IMHO. Unless an actual demonstrable improvement is seen, perhaps over a larger series removing a large number of so called redundant calls, it's just an additional source of confusion (due to gating at multiple levels) as far as I'm concerned.
Ian.
Quoted 7 lines
For booting a single guest, noone will notice. Booting 10 or more at a time however is very different.
XenServer, along with all other virtualisation platforms live in a world where "Net time to boot $N guests" (where N is measured in hundreds) is an important quantity, and needless overhead from things like this cause dom0 needless load that it would rather do without.
That's fine.
Quoted 2 lines
I should say that I have not done any performance metrics on this - as noted in the patch I stumbled upon it with valgrind.
And in the absence of such performance metrics I see no reason to apply this patch, which was what my initial reply said.
Ian.
Quoted 7 lines · Ian Jackson
Andrew Cooper writes ("[PATCH]
tools/libxc: Avoid hypercalls for cacheflush on x86"):Quoted 3 lines
XEN_DOMCTL_cacheflushhypercalls are-ENOSYSon x86. As domain creation/migration is already very hypercall-heavy, avoid making extra redundant hypercallsSurely this should be done by moving the relevant code to an arm-specific file, not by #ifdeffery.
I think it is very debatable that sort-circuiting a single ENOSYS hypercall in the tools is even worth it at all. "very hypercall heavy" doesn't cut it as a rationale IMHO. Unless an actual demonstrable improvement is seen, perhaps over a larger series removing a large number of so called redundant calls, it's just an additional source of confusion (due to gating at multiple levels) as far as I'm concerned.
Ian.
tools/libxc/xc_domain.c int xc_domain_create(xc_interface *xch, · line 57
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
tools/libxc/xc_domain.c +4
-0@@ -51,12 +51,18 @@ 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__) +/* This is not implemented or needed for x86. Avoid repeatedly going to +* Xen to find -ENOSYS. */ +return -ENOSYS ;
Leaving aside the question of whether this is worthwhile in the first place, this is wrong: You want to return -1 here, setting errno to ENOSYS.
Jan