]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
xl: Fix 'free_memory' to include outstanding_claims value.
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 12 Apr 2013 16:43:53 +0000 (12:43 -0400)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 16 Apr 2013 15:21:50 +0000 (16:21 +0100)
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>
docs/man/xl.conf.pod.5
docs/man/xl.pod.1
tools/libxl/libxl.c
tools/libxl/xl_cmdimpl.c

index c4072aa7e475e9a6a110680e4347bd4b3e3d0819..1229c8aedbbdde39467dfd0dbe62991a6bb81ba7 100644 (file)
@@ -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)
index 01ecc8343399724f2c4ba2f4bc2062346f8b889d..57c6a79174284373ab79308fd0dc7e030a33050f 100644 (file)
@@ -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>
 
index c9905e319be649ddcf5fc2779093d6975b747f93..03a9782de1439e2226fc9665eaa0bacf37d5e7b5 100644 (file)
@@ -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)
index 09b0f4145729598d2bb77a2119c58f0712e413a5..98ecf67da9ce5488908f8f34a483e383c7c78618 100644 (file)
@@ -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");