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

[Xen-devel] [PATCH] tmem: add basic tmem freeable info to xentop



Add tmem-freeable info to xentop when tmem is active

(No change to xentop output when tmem is inactive.)

Signed-off-by: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>

diff -r d0b030008814 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Fri Nov 27 08:09:26 2009 +0000
+++ b/tools/libxc/xenctrl.h     Mon Nov 30 10:54:39 2009 -0700
@@ -32,6 +32,7 @@
 #include <xen/xsm/acm.h>
 #include <xen/xsm/acm_ops.h>
 #include <xen/xsm/flask_op.h>
+#include <xen/tmem.h>
 
 #if defined(__i386__) || defined(__x86_64__)
 #include <xen/foreign/x86_32.h>
diff -r d0b030008814 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Fri Nov 27 08:09:26 2009 +0000
+++ b/tools/python/xen/xm/main.py       Mon Nov 30 10:54:39 2009 -0700
@@ -220,7 +220,7 @@ SUBCOMMAND_HELP = {
     'tmem-set'      :  ('[<Domain>|-a|--all] [weight=<weight>] [cap=<cap>] '
                         '[compress=<compress>]',
                         'Change tmem settings.'),
-    'tmem-freeable'  :  ('', 'Print number of freeable tmem pages.'),
+    'tmem-freeable'  :  ('', 'Print freeable tmem (in MiB).'),
     'tmem-shared-auth' :  ('[<Domain>|-a|--all] [--uuid=<uuid>] 
[--auth=<0|1>]', 'De/authenticate shared tmem pool.'),
 
     # security
diff -r d0b030008814 tools/xenstat/libxenstat/src/xenstat.c
--- a/tools/xenstat/libxenstat/src/xenstat.c    Fri Nov 27 08:09:26 2009 +0000
+++ b/tools/xenstat/libxenstat/src/xenstat.c    Mon Nov 30 10:54:39 2009 -0700
@@ -154,12 +154,16 @@ xenstat_node *xenstat_get_node(xenstat_h
                return NULL;
        }
 
+
        node->cpu_hz = ((unsigned long long)physinfo.cpu_khz) * 1000ULL;
         node->num_cpus = physinfo.nr_cpus;
        node->tot_mem = ((unsigned long long)physinfo.total_pages)
            * handle->page_size;
        node->free_mem = ((unsigned long long)physinfo.free_pages)
            * handle->page_size;
+
+       node->freeable_mb = (long)xc_tmem_control(handle->xc_handle, -1,
+                               TMEMC_QUERY_FREEABLE_MB, -1, 0, 0, 0, NULL);
 
        /* malloc(0) is not portable, so allocate a single domain.  This will
         * be resized below. */
@@ -302,6 +306,11 @@ unsigned long long xenstat_node_free_mem
 unsigned long long xenstat_node_free_mem(xenstat_node * node)
 {
        return node->free_mem;
+}
+
+long xenstat_node_freeable_mb(xenstat_node * node)
+{
+       return node->freeable_mb;
 }
 
 unsigned int xenstat_node_num_domains(xenstat_node * node)
diff -r d0b030008814 tools/xenstat/libxenstat/src/xenstat.h
--- a/tools/xenstat/libxenstat/src/xenstat.h    Fri Nov 27 08:09:26 2009 +0000
+++ b/tools/xenstat/libxenstat/src/xenstat.h    Mon Nov 30 10:54:39 2009 -0700
@@ -69,6 +69,9 @@ unsigned long long xenstat_node_tot_mem(
 /* Get amount of free memory on a node */
 unsigned long long xenstat_node_free_mem(xenstat_node * node);
 
+/* Get amount of tmem freeable memory (in MiB) on a node */
+long xenstat_node_freeable_mb(xenstat_node * node);
+
 /* Find the number of domains existing on a node */
 unsigned int xenstat_node_num_domains(xenstat_node * node);
 
diff -r d0b030008814 tools/xenstat/libxenstat/src/xenstat_priv.h
--- a/tools/xenstat/libxenstat/src/xenstat_priv.h       Fri Nov 27 08:09:26 
2009 +0000
+++ b/tools/xenstat/libxenstat/src/xenstat_priv.h       Mon Nov 30 10:54:39 
2009 -0700
@@ -49,6 +49,7 @@ struct xenstat_node {
        unsigned long long free_mem;
        unsigned int num_domains;
        xenstat_domain *domains;        /* Array of length num_domains */
+       long freeable_mb;
 };
 
 struct xenstat_domain {
diff -r d0b030008814 tools/xenstat/xentop/xentop.c
--- a/tools/xenstat/xentop/xentop.c     Fri Nov 27 08:09:26 2009 +0000
+++ b/tools/xenstat/xentop/xentop.c     Mon Nov 30 10:54:39 2009 -0700
@@ -799,6 +799,7 @@ void do_summary(void)
                 crash = 0, dying = 0, shutdown = 0;
        unsigned i, num_domains = 0;
        unsigned long long used = 0;
+       long freeable_mb = 0;
        xenstat_domain *domain;
        time_t curt;
 
@@ -825,12 +826,18 @@ void do_summary(void)
              num_domains, run, block, pause, crash, dying, shutdown);
 
        used = xenstat_node_tot_mem(cur_node)-xenstat_node_free_mem(cur_node);
+       freeable_mb = xenstat_node_freeable_mb(cur_node);
 
        /* Dump node memory and cpu information */
-       print("Mem: %lluk total, %lluk used, %lluk free    "
-             "CPUs: %u @ %lluMHz\n",
+       if ( freeable_mb <= 0 )
+            print("Mem: %lluk total, %lluk used, %lluk free    ",
              xenstat_node_tot_mem(cur_node)/1024, used/1024,
-             xenstat_node_free_mem(cur_node)/1024,
+             xenstat_node_free_mem(cur_node)/1024);
+       else
+            print("Mem: %lluk total, %lluk used, %lluk free, %ldk freeable, ",
+             xenstat_node_tot_mem(cur_node)/1024, used/1024,
+             xenstat_node_free_mem(cur_node)/1024, freeable_mb*1024);
+       print("CPUs: %u @ %lluMHz\n",
              xenstat_node_num_cpus(cur_node),
              xenstat_node_cpu_hz(cur_node)/1000000);
 }

Attachment: tmem-xentop.patch
Description: Binary data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

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