aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2013-05-13 15:29:11 -0400
committerIan Campbell <ian.campbell@citrix.com>2013-05-14 10:01:50 +0100
commitbec8f17e48439ee5b8370f4e431ccd9a9514bee7 (patch)
tree59b77ff052dcef3826e1f54a5eb183ae5ceac18a /tools/libxl
parentabf04cf04f5b6f2ce22e9f7966d63303b9487d81 (diff)
downloadxen-bec8f17e48439ee5b8370f4e431ccd9a9514bee7.tar.gz
xen-bec8f17e48439ee5b8370f4e431ccd9a9514bee7.tar.bz2
xen-bec8f17e48439ee5b8370f4e431ccd9a9514bee7.zip
hypervisor/xen/tools: Remove the XENMEM_get_oustanding_pages and provide the data via xc_phys_info
During the review of the patches it was noticed that there exists a race wherein the 'free_memory' value consists of information from two hypercalls. That is the XEN_SYSCTL_physinfo and XENMEM_get_outstanding_pages. The free memory the host has available for guest is the difference between the 'free_pages' (from XEN_SYSCTL_physinfo) and 'outstanding_pages'. As they are two hypercalls many things can happen in between the execution of them. This patch resolves this by eliminating the XENMEM_get_outstanding_pages hypercall and providing the free_pages and outstanding_pages information via the xc_phys_info structure. It also removes the XSM hooks and adds locking as needed. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Reviewed-by: Tim Deegan <tim@xen.org> Acked-by: Keir Fraser <keir.xen@gmail.com>
Diffstat (limited to 'tools/libxl')
-rw-r--r--tools/libxl/libxl.c15
-rw-r--r--tools/libxl/libxl.h1
-rw-r--r--tools/libxl/libxl_types.idl1
-rw-r--r--tools/libxl/xl_cmdimpl.c16
4 files changed, 5 insertions, 28 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index bc91fd5abf..ee1fa9cf8c 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -3942,6 +3942,7 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
physinfo->total_pages = xcphysinfo.total_pages;
physinfo->free_pages = xcphysinfo.free_pages;
physinfo->scrub_pages = xcphysinfo.scrub_pages;
+ physinfo->outstanding_pages = xcphysinfo.outstanding_pages;
l = xc_sharing_freed_pages(ctx->xch);
if (l == -ENOSYS) {
l = 0;
@@ -4105,20 +4106,6 @@ libxl_numainfo *libxl_get_numainfo(libxl_ctx *ctx, int *nr)
return ret;
}
-uint64_t libxl_get_claiminfo(libxl_ctx *ctx)
-{
- long l;
-
- l = xc_domain_get_outstanding_pages(ctx->xch);
- if (l < 0) {
- LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_WARNING, l,
- "xc_domain_get_outstanding_pages failed.");
- return ERROR_FAIL;
- }
- /* In pages */
- return l;
-}
-
const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx)
{
union {
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index ef96bce1a7..0bc005e0ee 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -624,7 +624,6 @@ int libxl_wait_for_free_memory(libxl_ctx *ctx, uint32_t domid, uint32_t memory_k
/* wait for the memory target of a domain to be reached */
int libxl_wait_for_memory_target(libxl_ctx *ctx, uint32_t domid, int wait_secs);
-uint64_t libxl_get_claiminfo(libxl_ctx *ctx);
int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass);
int libxl_console_exec(libxl_ctx *ctx, uint32_t domid, int cons_num, libxl_console_type type);
/* libxl_primary_console_exec finds the domid and console number
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index ecf1f0bc4f..8262cba623 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -487,6 +487,7 @@ libxl_physinfo = Struct("physinfo", [
("total_pages", uint64),
("free_pages", uint64),
("scrub_pages", uint64),
+ ("outstanding_pages", uint64),
("sharing_freed_pages", uint64),
("sharing_used_frames", uint64),
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index c1a969b80c..edf0325fdd 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -4576,21 +4576,11 @@ static void output_physinfo(void)
unsigned int i;
libxl_bitmap cpumap;
int n = 0;
- long claims = 0;
if (libxl_get_physinfo(ctx, &info) != 0) {
fprintf(stderr, "libxl_physinfo failed.\n");
return;
}
- /*
- * Don't bother checking "claim_mode" as user might have turned it off
- * and we have outstanding claims.
- */
- if ((claims = libxl_get_claiminfo(ctx)) < 0){
- fprintf(stderr, "libxl_get_claiminfo failed. errno: %d (%s)\n",
- errno, strerror(errno));
- return;
- }
printf("nr_cpus : %d\n", info.nr_cpus);
printf("max_cpu_id : %d\n", info.max_cpu_id);
printf("nr_nodes : %d\n", info.nr_nodes);
@@ -4610,15 +4600,15 @@ static void output_physinfo(void)
if (vinfo) {
i = (1 << 20) / vinfo->pagesize;
printf("total_memory : %"PRIu64"\n", info.total_pages / i);
- printf("free_memory : %"PRIu64"\n", (info.free_pages - claims) / i);
+ printf("free_memory : %"PRIu64"\n", (info.free_pages - info.outstanding_pages) / i);
printf("sharing_freed_memory : %"PRIu64"\n", info.sharing_freed_pages / i);
printf("sharing_used_memory : %"PRIu64"\n", info.sharing_used_frames / i);
}
/*
* Only if enabled (claim_mode=1) or there are outstanding claims.
*/
- if (libxl_defbool_val(claim_mode) || claims)
- printf("outstanding_claims : %ld\n", claims / i);
+ if (libxl_defbool_val(claim_mode) || info.outstanding_pages)
+ printf("outstanding_claims : %"PRIu64"\n", info.outstanding_pages / i);
if (!libxl_get_freecpus(ctx, &cpumap)) {
libxl_for_each_bit(i, cpumap)