tools: libxl: do not set the PoD target on ARM
PATCH 1/1 tools: libxl: do not set the PoD target on ARM
ARM does not implemented PoD and so returns ENOSYS from XENMEM_set_pod_target.
The correct solution here would be to check for ENOSYS in libxl, unfortunately xc_domain_set_pod_target suffers from the same broken error reporting as the rest of libxc and throws away the errno.
So for now conditionally define xc_domain_set_pod_target to return success (which is what PoD does if nothing needs doing). xc_domain_get_pod_target sets errno==-1 and returns -1, which matches the broken error reporting of the existing function. It appears to have no in tree callers in any case.
The conditional should be removed once libxc has been fixed.
This makes ballooning (xl mem-set) work for ARM domains.
---
I'd be generally wary of modifying the error handling in a piecemeal way, but certainly doing so for 4.4 now would be inapropriate.
IIRC Ian J was planning a thorough sweep of the libxc error paths in 4.5 time frame, at which point this conditional stuff could be dropped.
In terms of the 4.4 release, obviously ballooning would be very nice to have for ARM guests, on the other hand I'm aware that while the patch is fairly small/contained and safe it is also pretty skanky and likely wouldn't be accepted outside of the rc period.
--- tools/libxc/xc_domain.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
tools/libxc/xc_domain.c +28 -0
@@ -986,6 +986,12 @@ out:return rc; } +/* Currently only implemented on x86. This cannot be handled in the +* caller, e.g. by looking for errno==ENOSYS because of the broken +* error reporting style. Once this is fixed then this condition can +* be removed. +*/ +#if defined(__i386__)||defined(__x86_64__) static int xc_domain_pod_target(xc_interface *xch, int op, uint32_t domid,
@@ -1055,6 +1061,28 @@ int xc_domain_get_pod_target(xc_interface *xch, pod_cache_pages, pod_entries); } +#else +int xc_domain_set_pod_target (xc_interface *xch, +uint32_t domid, +uint64_t target_pages, +uint64_t *tot_pages, +uint64_t *pod_cache_pages, +uint64_t *pod_entries) +{ +return 0 ; +} +int xc_domain_get_pod_target (xc_interface *xch, +uint32_t domid, +uint64_t *tot_pages, +uint64_t *pod_cache_pages, +uint64_t *pod_entries) +{ +/* On x86 (above) xc_domain_pod_target will incorrectly return -1 +* with errno==-1 on error. Do the same for least surprise. */ + errno =-1 ; +return -1 ; +} +#endif int xc_domain_max_vcpus (xc_interface *xch,uint32_t domid,unsigned int max) {
Signature · 1 line
1.7.10.4
Quoted 21 lines · Ian Campbell
ARM does not implemented PoD and so returns ENOSYS from
XENMEM_set_pod_target.The correct solution here would be to check for ENOSYS in libxl, unfortunately
xc_domain_set_pod_targetsuffers from the same broken error reporting as the rest of libxc and throws away the errno.So for now conditionally define
xc_domain_set_pod_targetto return success (which is what PoD does if nothing needs doing).xc_domain_get_pod_targetsets errno==-1 and returns -1, which matches the broken error reporting of the existing function. It appears to have no in tree callers in any case.The conditional should be removed once libxc has been fixed.
This makes ballooning (xl mem-set) work for ARM domains.
Signed-off-by Ian Campbell <[email protected]>---
I'd be generally wary of modifying the error handling in a piecemeal way, but certainly doing so for 4.4 now would be inapropriate.
Quoted 7 lines
IIRC Ian J was planning a thorough sweep of the libxc error paths in 4.5 time frame, at which point this conditional stuff could be dropped.
In terms of the 4.4 release, obviously ballooning would be very nice to have for ARM guests, on the other hand I'm aware that while the patch is fairly small/contained and safe it is also pretty skanky and likely wouldn't be accepted outside of the rc period.
George -- what do you think of this?
Quoted 50 lines
--- tools/libxc/xc_domain.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)tools/libxc/xc_domain.c +28
-0@@ -986,6 +986,12 @@ out:return rc; } +/* Currently only implemented on x86. This cannot be handled in the +* caller, e.g. by looking for errno==ENOSYS because of the broken +* error reporting style. Once this is fixed then this condition can +* be removed. +*/ +#if defined(__i386__)||defined(__x86_64__) static int xc_domain_pod_target(xc_interface *xch, int op, uint32_t domid,@@ -1055,6 +1061,28 @@ int xc_domain_get_pod_target(xc_interface *xch, pod_cache_pages, pod_entries); } +#else +int xc_domain_set_pod_target (xc_interface *xch, +uint32_t domid, +uint64_t target_pages, +uint64_t *tot_pages, +uint64_t *pod_cache_pages, +uint64_t *pod_entries) +{ +return 0 ; +} +int xc_domain_get_pod_target (xc_interface *xch, +uint32_t domid, +uint64_t *tot_pages, +uint64_t *pod_cache_pages, +uint64_t *pod_entries) +{ +/* On x86 (above) xc_domain_pod_target will incorrectly return -1 +* with errno==-1 on error. Do the same for least surprise. */ + errno =-1 ; +return -1 ; +} +#endif int xc_domain_max_vcpus (xc_interface *xch,uint32_t domid,unsigned int max) {
Quoted 25 lines · Ian Campbell
Quoted 24 lines · Ian Campbell
ARM does not implemented PoD and so returns ENOSYS from
XENMEM_set_pod_target.The correct solution here would be to check for ENOSYS in libxl, unfortunately
xc_domain_set_pod_targetsuffers from the same broken error reporting as the rest of libxc and throws away the errno.So for now conditionally define
xc_domain_set_pod_targetto return success (which is what PoD does if nothing needs doing).xc_domain_get_pod_targetsets errno==-1 and returns -1, which matches the broken error reporting of the existing function. It appears to have no in tree callers in any case.The conditional should be removed once libxc has been fixed.
This makes ballooning (xl mem-set) work for ARM domains.
Signed-off-by Ian Campbell <[email protected]>---
I'd be generally wary of modifying the error handling in a piecemeal way, but certainly doing so for 4.4 now would be inapropriate.IIRC Ian J was planning a thorough sweep of the libxc error paths in 4.5 time frame, at which point this conditional stuff could be dropped.
Quoted 6 lines
Quoted 4 lines
In terms of the 4.4 release, obviously ballooning would be very nice to have for ARM guests, on the other hand I'm aware that while the patch is fairly small/contained and safe it is also pretty skanky and likely wouldn't be accepted outside of the rc period.
George -- what do you think of this?
So is this actually called in the arm domain build code at the moment?
-George
Quoted 26 lines · George Dunlap
Quoted 25 lines · Ian Campbell
Quoted 24 lines · Ian Campbell
ARM does not implemented PoD and so returns ENOSYS from
XENMEM_set_pod_target.The correct solution here would be to check for ENOSYS in libxl, unfortunately
xc_domain_set_pod_targetsuffers from the same broken error reporting as the rest of libxc and throws away the errno.So for now conditionally define
xc_domain_set_pod_targetto return success (which is what PoD does if nothing needs doing).xc_domain_get_pod_targetsets errno==-1 and returns -1, which matches the broken error reporting of the existing function. It appears to have no in tree callers in any case.The conditional should be removed once libxc has been fixed.
This makes ballooning (xl mem-set) work for ARM domains.
Signed-off-by Ian Campbell <[email protected]>---
I'd be generally wary of modifying the error handling in a piecemeal way, but certainly doing so for 4.4 now would be inapropriate.IIRC Ian J was planning a thorough sweep of the libxc error paths in 4.5 time frame, at which point this conditional stuff could be dropped.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
In terms of the 4.4 release, obviously ballooning would be very nice to have for ARM guests, on the other hand I'm aware that while the patch is fairly small/contained and safe it is also pretty skanky and likely wouldn't be accepted outside of the rc period.
George -- what do you think of this?
So is this actually called in the arm domain build code at the moment?
It is common code in libxl which calls into it. I originally had the ifdef there instead.
(I've just noticed that I forgot to update $subject when I moved the #ifdef from libxl to libxc)
Ian.
Quoted 34 lines · Ian Campbell
Quoted 33 lines · George Dunlap
Quoted 31 lines · Ian Campbell
Quoted 21 lines · Ian Campbell
ARM does not implemented PoD and so returns ENOSYS from
XENMEM_set_pod_target.The correct solution here would be to check for ENOSYS in libxl, unfortunately
xc_domain_set_pod_targetsuffers from the same broken error reporting as the rest of libxc and throws away the errno.So for now conditionally define
xc_domain_set_pod_targetto return success (which is what PoD does if nothing needs doing).xc_domain_get_pod_targetsets errno==-1 and returns -1, which matches the broken error reporting of the existing function. It appears to have no in tree callers in any case.The conditional should be removed once libxc has been fixed.
This makes ballooning (xl mem-set) work for ARM domains.
Signed-off-by Ian Campbell <[email protected]>---
I'd be generally wary of modifying the error handling in a piecemeal way, but certainly doing so for 4.4 now would be inapropriate.Quoted 7 lines
IIRC Ian J was planning a thorough sweep of the libxc error paths in 4.5 time frame, at which point this conditional stuff could be dropped.
In terms of the 4.4 release, obviously ballooning would be very nice to have for ARM guests, on the other hand I'm aware that while the patch is fairly small/contained and safe it is also pretty skanky and likely wouldn't be accepted outside of the rc period.
George -- what do you think of this?
Quoted 7 lines
Quoted 1 line
So is this actually called in the arm domain build code at the moment?
It is common code in libxl which calls into it. I originally had the ifdef there instead.
(I've just noticed that I forgot to update $subject when I moved the #ifdef from libxl to libxc)
Oh, right -- yes, you normally need to call set_pod_target() every time you update the balloon target, just in case PoD mode was activated on boot; if it wasn't (or if all the PoD entries have gone away) this will be a noop.
The only conceptual issue with putting it here is that xc_domain_set_pod_target() is also called during domain creation to fill the PoD "cache" with the domain's memory, from which to populate the p2m on-demand. So if "someone" were to try to add PoD to the ARM guest creation, and forgot about this hack, they might spend a bit of time figuring out why the initial call to fill the PoD cache was succeeding but the guest was crashing with "PoD empty cache" anyway.
(xc_domain_set_target behaves differently if there are no entries in the p2m than if there are: if the p2m is empty, it will respond to this by filling the cache; if it's non-empty, it will ignore changes if there are no outstanding p2m entries. That made sense at the time, but now it looks like a bit of an interface trap for the unwary...)
Was there a reason to put this in libxc rather than libxc? We don't expect anyone to call libxc, so having it libxc isn't a big deal, but conceptually it would probably be safer in libxl.
-George
Quoted 3 lines · George Dunlap
Was there a reason to put this in libxc rather than libxc? We don't expect anyone to call libxc, so having it libxc isn't a big deal, but conceptually it would probably be safer in libxl.
Er, change the 2nd "libxc" to "libxl" in this sentence, and it will probably make a bit more sense...
-George
Quoted 48 lines · George Dunlap
Quoted 34 lines · Ian Campbell
Quoted 33 lines · George Dunlap
Quoted 31 lines · Ian Campbell
Quoted 21 lines · Ian Campbell
ARM does not implemented PoD and so returns ENOSYS from
XENMEM_set_pod_target.The correct solution here would be to check for ENOSYS in libxl, unfortunately
xc_domain_set_pod_targetsuffers from the same broken error reporting as the rest of libxc and throws away the errno.So for now conditionally define
xc_domain_set_pod_targetto return success (which is what PoD does if nothing needs doing).xc_domain_get_pod_targetsets errno==-1 and returns -1, which matches the broken error reporting of the existing function. It appears to have no in tree callers in any case.The conditional should be removed once libxc has been fixed.
This makes ballooning (xl mem-set) work for ARM domains.
Signed-off-by Ian Campbell <[email protected]>---
I'd be generally wary of modifying the error handling in a piecemeal way, but certainly doing so for 4.4 now would be inapropriate.Quoted 7 lines
IIRC Ian J was planning a thorough sweep of the libxc error paths in 4.5 time frame, at which point this conditional stuff could be dropped.
In terms of the 4.4 release, obviously ballooning would be very nice to have for ARM guests, on the other hand I'm aware that while the patch is fairly small/contained and safe it is also pretty skanky and likely wouldn't be accepted outside of the rc period.
George -- what do you think of this?
Quoted 7 lines
Quoted 1 line
So is this actually called in the arm domain build code at the moment?
It is common code in libxl which calls into it. I originally had the ifdef there instead.
(I've just noticed that I forgot to update $subject when I moved the #ifdef from libxl to libxc)
Oh, right -- yes, you normally need to call
set_pod_target()every time you update the balloon target, just in case PoD mode was activated on boot; if it wasn't (or if all the PoD entries have gone away) this will be a noop.
Quoted 7 lines
The only conceptual issue with putting it here is that
xc_domain_set_pod_target()is also called during domain creation to fill the PoD "cache" with the domain's memory, from which to populate the p2m on-demand. So if "someone" were to try to add PoD to the ARM guest creation, and forgot about this hack, they might spend a bit of time figuring out why the initial call to fill the PoD cache was succeeding but the guest was crashing with "PoD empty cache" anyway.
My hope is that this will get cleaned up in the 4.5 timeframe, as part of the overdue cleanup of libxc error handling. After that then this will properly report ENOSYS so that libxl can just DTRT. My hope is that this will happen before anyone gets to implementing PoD on ARM.
Anyway, if this is the biggest stumbling block someone has while adding PoD to ARM then they will have done pretty well...
Quoted 9 lines
(
xc_domain_set_targetbehaves differently if there are no entries in the p2m than if there are: if the p2m is empty, it will respond to this by filling the cache; if it's non-empty, it will ignore changes if there are no outstanding p2m entries. That made sense at the time, but now it looks like a bit of an interface trap for the unwary...)Was there a reason to put this in libxc rather than libxc? We don't expect anyone to call libxc, so having it libxc isn't a big deal, but conceptually it would probably be safer in libxl.
I just thought the hack was more contained in libxc is all. Also having it in libxc means that when the error handling cleanup I mentioned occurs this will cleaned up at the same time, whereas if it was an ifdef in libxl it might get missed. Not a big deal until someone implements PoD on ARM though...
Ian.
Quoted 75 lines · Ian Campbell
Quoted 48 lines · George Dunlap
Quoted 34 lines · Ian Campbell
Quoted 33 lines · George Dunlap
Quoted 31 lines · Ian Campbell
Quoted 21 lines · Ian Campbell
ARM does not implemented PoD and so returns ENOSYS from
XENMEM_set_pod_target.The correct solution here would be to check for ENOSYS in libxl, unfortunately
xc_domain_set_pod_targetsuffers from the same broken error reporting as the rest of libxc and throws away the errno.So for now conditionally define
xc_domain_set_pod_targetto return success (which is what PoD does if nothing needs doing).xc_domain_get_pod_targetsets errno==-1 and returns -1, which matches the broken error reporting of the existing function. It appears to have no in tree callers in any case.The conditional should be removed once libxc has been fixed.
This makes ballooning (xl mem-set) work for ARM domains.
Signed-off-by Ian Campbell <[email protected]>---
I'd be generally wary of modifying the error handling in a piecemeal way, but certainly doing so for 4.4 now would be inapropriate.Quoted 7 lines
IIRC Ian J was planning a thorough sweep of the libxc error paths in 4.5 time frame, at which point this conditional stuff could be dropped.
In terms of the 4.4 release, obviously ballooning would be very nice to have for ARM guests, on the other hand I'm aware that while the patch is fairly small/contained and safe it is also pretty skanky and likely wouldn't be accepted outside of the rc period.
George -- what do you think of this?
Quoted 7 lines
Quoted 1 line
So is this actually called in the arm domain build code at the moment?
It is common code in libxl which calls into it. I originally had the ifdef there instead.
(I've just noticed that I forgot to update $subject when I moved the #ifdef from libxl to libxc)
Oh, right -- yes, you normally need to call
set_pod_target()every time you update the balloon target, just in case PoD mode was activated on boot; if it wasn't (or if all the PoD entries have gone away) this will be a noop.Quoted 7 lines
The only conceptual issue with putting it here is that
xc_domain_set_pod_target()is also called during domain creation to fill the PoD "cache" with the domain's memory, from which to populate the p2m on-demand. So if "someone" were to try to add PoD to the ARM guest creation, and forgot about this hack, they might spend a bit of time figuring out why the initial call to fill the PoD cache was succeeding but the guest was crashing with "PoD empty cache" anyway.My hope is that this will get cleaned up in the 4.5 timeframe, as part of the overdue cleanup of libxc error handling. After that then this will properly report ENOSYS so that libxl can just DTRT. My hope is that this will happen before anyone gets to implementing PoD on ARM.
Anyway, if this is the biggest stumbling block someone has while adding PoD to ARM then they will have done pretty well...
Quoted 9 lines
(
xc_domain_set_targetbehaves differently if there are no entries in the p2m than if there are: if the p2m is empty, it will respond to this by filling the cache; if it's non-empty, it will ignore changes if there are no outstanding p2m entries. That made sense at the time, but now it looks like a bit of an interface trap for the unwary...)Was there a reason to put this in libxc rather than libxc? We don't expect anyone to call libxc, so having it libxc isn't a big deal, but conceptually it would probably be safer in libxl.
Quoted 5 lines
I just thought the hack was more contained in libxc is all. Also having it in libxc means that when the error handling cleanup I mentioned occurs this will cleaned up at the same time, whereas if it was an ifdef in libxl it might get missed. Not a big deal until someone implements PoD on ARM though...
OK -- well I guess whatever you want to do then. It's a bit of a bikeshed issue -- I've expressed my preference, go ahead and paint it whatever color you think best. :-)
If you want to check in this one:
Ian Jackson
Acked-byGeorge Dunlap writes ("Re: [Xen-devel] [PATCH] tools: libxl: do not set the PoD target on ARM"):
Quoted 3 lines
If you want to check in this one:
Release-acked-by George Dunlap <[email protected]>
(from a tools PoV)
Ian.
Julien Grall
Acked-byQuoted 6 lines · Ian Jackson
George Dunlap writes ("Re: [Xen-devel] [PATCH] tools: libxl: do not set the PoD target on ARM"):
Quoted 3 lines
If you want to check in this one:
Release-acked-by George Dunlap <[email protected]>Acked-by Ian Jackson <[email protected]>
Signature · 1 line
Julien Grall
Quoted 6 lines · Ian Jackson
George Dunlap writes ("Re: [Xen-devel] [PATCH] tools: libxl: do not set the PoD target on ARM"):
Quoted 3 lines
If you want to check in this one:
Release-acked-by George Dunlap <[email protected]>Acked-by Ian Jackson <[email protected]>
Between that, Julien's ack and George's Release-ack: Applied.
Thanks.