aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2013-04-12 12:43:53 -0400
committerIan Jackson <Ian.Jackson@eu.citrix.com>2013-04-16 16:21:50 +0100
commit65a11256f294882d6bd1af4af51e42dbbead650d (patch)
treed70f7467d876de6b3adb7691fe1fe474d70d2c16 /tools/libxl
parenteb42f98a20fd0315e9b50ffbaca822aef46214ab (diff)
downloadxen-65a11256f294882d6bd1af4af51e42dbbead650d.tar.gz
xen-65a11256f294882d6bd1af4af51e42dbbead650d.tar.bz2
xen-65a11256f294882d6bd1af4af51e42dbbead650d.zip
xl: Fix 'free_memory' to include outstanding_claims value.
Updating to make it clear that free_memory reported by 'xl info' is influenced by the outstanding claim value. That is the free memory that will be available to the host once all outstanding claims have been completed. This modifies the behavior that the patch titled "xl: 'xl info' print outstanding claims if enabled (claim_mode=1 in xl.conf)" had - which reported the outstanding claims and nothing else. The free_pages as reported by the hypervisor is the currently available count of pages on the heap. The outstanding pages is the total amount of pages reserved for guests (so not taken from the heap yet). As guests are being populated the memory from the heap shrinks and the outstanding count of pages decreases. The total memory used for guests increases. As the available count of pages on the heap and outstanding claims are intertwined, report the amount of free memory available to be a combination of that. That is free heap memory minus the outstanding pages. We also make some odd choices in reporting. By default we will only display 'outstanding_claims' if the claim_mode is enabled in the global configuration file. However, if there are outstanding claims, we will ignore the claim_mode and report these values. Suggested-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'tools/libxl')
-rw-r--r--tools/libxl/libxl.c4
-rw-r--r--tools/libxl/xl_cmdimpl.c45
2 files changed, 19 insertions, 30 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index c9905e319b..03a9782de1 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -4068,8 +4068,8 @@ uint64_t libxl_get_claiminfo(libxl_ctx *ctx)
"xc_domain_get_outstanding_pages failed.");
return ERROR_FAIL;
}
- /* In MB */
- return (l >> 8);
+ /* In pages */
+ return l;
}
const libxl_version_info* libxl_get_version_info(libxl_ctx *ctx)
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 09b0f41457..98ecf67da9 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -4575,12 +4575,21 @@ 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);
@@ -4600,10 +4609,16 @@ 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 / i);
+ printf("free_memory : %"PRIu64"\n", (info.free_pages - claims) / 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_get_freecpus(ctx, &cpumap)) {
libxl_for_each_bit(i, cpumap)
if (libxl_bitmap_test(&cpumap, i))
@@ -4611,7 +4626,6 @@ static void output_physinfo(void)
printf("free_cpus : %d\n", n);
free(cpumap.map);
}
-
libxl_physinfo_dispose(&info);
return;
}
@@ -4671,29 +4685,6 @@ static void output_topologyinfo(void)
return;
}
-static void output_claim(void)
-{
- long l;
-
- /*
- * Note that the xl.c (which calls us) has already read from the
- * global configuration the 'claim_mode' value.
- */
- if (!libxl_defbool_val(claim_mode))
- return;
-
- l = libxl_get_claiminfo(ctx);
- if (l < 0) {
- fprintf(stderr, "libxl_get_claiminfo failed. errno: %d (%s)\n",
- errno, strerror(errno));
- return;
- }
-
- printf("outstanding_claims : %ld\n", l);
-
- return;
-}
-
static void print_info(int numa)
{
output_nodeinfo();
@@ -4704,8 +4695,6 @@ static void print_info(int numa)
output_topologyinfo();
output_numainfo();
}
- output_claim();
-
output_xeninfo();
printf("xend_config_format : 4\n");