[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 6/6] xl: 'xl list' supports '-c' for global claim information.



When guests have XENMEM_claim_pages called, they influence a global
counter value - which has the cumulative count of the number of
pages requested by all domains. This value is provided via the
XENMEM_get_unclaimed_pages hypercall. The value fluctuates quite
often so the value is stale once it is provided to the user-space.
However it is useful for diagnostic purposes.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
 tools/libxc/xc_domain.c     |  4 ++++
 tools/libxc/xenctrl.h       |  2 ++
 tools/libxl/libxl.c         | 12 ++++++++++++
 tools/libxl/libxl.h         |  1 +
 tools/libxl/libxl_types.idl |  4 ++++
 tools/libxl/xl_cmdimpl.c    | 29 +++++++++++++++++++++++++----
 tools/libxl/xl_cmdtable.c   |  4 +++-
 7 files changed, 51 insertions(+), 5 deletions(-)

diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 6aefde9..151ad4c 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -796,6 +796,10 @@ int xc_domain_claim_pages(xc_interface *xch,
     err = do_memory_op(xch, XENMEM_claim_pages, &reservation, 
sizeof(reservation));
     return err;
 }
+unsigned long xc_domain_get_unclaimed_pages(xc_interface *xch)
+{
+    return do_memory_op(xch, XENMEM_get_unclaimed_pages, NULL, 0);
+}
 
 int xc_domain_populate_physmap(xc_interface *xch,
                                uint32_t domid,
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index ba1fa14..96b3086 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -1135,6 +1135,8 @@ int xc_domain_claim_pages(xc_interface *xch,
                                unsigned long nr_pages,
                                unsigned int claim_flags);
 
+unsigned long xc_domain_get_unclaimed_pages(xc_interface *xch);
+
 int xc_domain_memory_exchange_pages(xc_interface *xch,
                                     int domid,
                                     unsigned long nr_in_extents,
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 9c6968f..42a28f4 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -4051,6 +4051,18 @@ libxl_numainfo *libxl_get_numainfo(libxl_ctx *ctx, int 
*nr)
     return ret;
 }
 
+int libxl_get_claiminfo(libxl_ctx *ctx, libxl_claiminfo *claiminfo)
+{
+    long l;
+
+    l = xc_domain_get_unclaimed_pages(ctx->xch);
+    if (l == -ENOSYS)
+        return l;
+    claiminfo->claimed = l;
+
+    return 0;
+}
+
 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 538bf93..8d0ab23 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -581,6 +581,7 @@ int libxl_wait_for_memory_target(libxl_ctx *ctx, uint32_t 
domid, int wait_secs);
 
 /* Parse the claim_mode options */
 int libxl_parse_claim_mode(const char *s, unsigned int *flag);
+int libxl_get_claiminfo(libxl_ctx *ctx, libxl_claiminfo *claiminfo);
 
 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);
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index b479c60..8c6e9b6 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -510,6 +510,10 @@ libxl_cputopology = Struct("cputopology", [
     ("node", uint32),
     ], dir=DIR_OUT)
 
+libxl_claiminfo = Struct("claiminfo", [
+    ("claimed", uint64),
+    ])
+
 libxl_sched_credit_params = Struct("sched_credit_params", [
     ("tslice_ms", integer),
     ("ratelimit_us", integer),
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 27298ea..6687c01 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -4640,7 +4640,23 @@ static void output_topologyinfo(void)
     return;
 }
 
-static void print_info(int numa)
+static void output_claim(void)
+{
+    libxl_claiminfo info;
+
+    if (libxl_get_claiminfo(ctx, &info)) {
+        fprintf(stderr, "libxl_get_claiminfo failed.\n");
+        return;
+    }
+
+    printf("claim mode             : %s (%ld)\n",
+           libxl_claim_mode_to_string(global_claim_mode), info.claimed);
+
+    libxl_claiminfo_dispose(&info);
+    return;
+}
+
+static void print_info(int numa, int claim)
 {
     output_nodeinfo();
 
@@ -4650,6 +4666,8 @@ static void print_info(int numa)
         output_topologyinfo();
         output_numainfo();
     }
+    if (claim)
+        output_claim();
 
     output_xeninfo();
 
@@ -4663,18 +4681,21 @@ int main_info(int argc, char **argv)
     int opt;
     static struct option opts[] = {
         {"numa", 0, 0, 'n'},
+        {"claim", 0, 0, 'c'},
         COMMON_LONG_OPTS,
         {0, 0, 0, 0}
     };
-    int numa = 0;
+    int numa = 0, claim = 0;
 
-    SWITCH_FOREACH_OPT(opt, "hn", opts, "info", 0) {
+    SWITCH_FOREACH_OPT(opt, "hnc", opts, "info", 0) {
     case 'n':
         numa = 1;
         break;
+    case 'c':
+        claim = 1;
     }
 
-    print_info(numa);
+    print_info(numa, claim);
     return 0;
 }
 
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index b4a87ca..a48dbb0 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -226,7 +226,9 @@ struct cmd_spec cmd_table[] = {
     { "info",
       &main_info, 0, 0,
       "Get information about Xen host",
-      "-n, --numa         List host NUMA topology information",
+      "[-n|-c]",
+      "-n, --numa         List host NUMA topology information\n"
+      "-c, --claim        List claim information",
     },
     { "sharing",
       &main_sharing, 0, 0,
-- 
1.8.0.2


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.