[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 7/7] 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@xxxxxxxxxxxxx> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> --- docs/man/xl.conf.pod.5 | 2 ++ docs/man/xl.pod.1 | 8 ++++++-- tools/libxl/libxl.c | 4 ++-- tools/libxl/xl_cmdimpl.c | 45 +++++++++++++++++---------------------------- 4 files changed, 27 insertions(+), 32 deletions(-) diff --git a/docs/man/xl.conf.pod.5 b/docs/man/xl.conf.pod.5 index c4072aa..1229c8a 100644 --- a/docs/man/xl.conf.pod.5 +++ b/docs/man/xl.conf.pod.5 @@ -126,6 +126,8 @@ quickly and the amount of free memory (which C<xl info> can show) is stale the moment it is printed. When claim is enabled a reservation for the amount of memory (see 'memory' in xl.conf(5)) is set, which is then reduced as the domain's memory is populated and eventually reaches zero. +The free memory in C<xl info> is the combination of the hypervisor's +free heap memory minus the outstanding claims value. If the reservation cannot be meet the guest creation fails immediately instead of taking seconds/minutes (depending on the size of the guest) diff --git a/docs/man/xl.pod.1 b/docs/man/xl.pod.1 index 01ecc83..57c6a79 100644 --- a/docs/man/xl.pod.1 +++ b/docs/man/xl.pod.1 @@ -737,7 +737,8 @@ the feature bits returned by the cpuid command on x86 platforms. =item B<free_memory> -Available memory (in MB) not allocated to Xen, or any other domains. +Available memory (in MB) not allocated to Xen, or any other domains, or +claimed for domains. =item B<outstanding_claims> @@ -746,7 +747,10 @@ amount of pages is set and also a global value is incremented. This global value (outstanding_claims) is then reduced as the domain's memory is populated and eventually reaches zero. Most of the time the value will be zero, but if you are launching multiple guests, and B<claim_mode> is -enabled, this value can increase/decrease. +enabled, this value can increase/decrease. Note that the value also +affects the B<free_memory> - as it will reflect the free memory +in the hypervisor minus the outstanding pages claimed for guests. +See xl I<info> B<claims> parameter for detailed listing. =item B<xen_caps> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index c9905e3..03a9782 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 09b0f41..98ecf67 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"); -- 1.8.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |