WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] tmem/xentop: add useful tmem output to xentop

To: "Xen-Devel (E-mail)" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] tmem/xentop: add useful tmem output to xentop
From: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>
Date: Tue, 8 Dec 2009 16:56:58 -0800 (PST)
Delivery-date: Tue, 08 Dec 2009 16:59:12 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Report a few key per-domain tmem statistics in xentop.

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

diff -r 7f611de6b93c tools/xenstat/libxenstat/src/xenstat.c
--- a/tools/xenstat/libxenstat/src/xenstat.c    Tue Dec 08 14:14:27 2009 +0000
+++ b/tools/xenstat/libxenstat/src/xenstat.c    Tue Dec 08 17:16:29 2009 -0700
@@ -131,6 +131,32 @@ void xenstat_uninit(xenstat_handle * han
        }
 }
 
+static inline unsigned long long parse(char *s, char *match)
+{
+       char *s1 = strstr(s,match);
+       unsigned long long ret;
+
+       if ( s1 == NULL )
+               return 0LL;
+       s1 += 2;
+       if ( *s1++ != ':' )
+               return 0LL;
+       sscanf(s1,"%llu",&ret);
+       return ret;
+}
+
+void domain_get_tmem_stats(xenstat_handle * handle, xenstat_domain * domain)
+{
+       char buffer[4096];
+
+       xc_tmem_control(handle->xc_handle,-1,TMEMC_LIST,domain->id,
+                        sizeof(buffer),-1,-1,buffer);
+       domain->tmem_stats.curr_eph_pages = parse(buffer,"Ec");
+       domain->tmem_stats.succ_eph_gets = parse(buffer,"Ge");
+       domain->tmem_stats.succ_pers_puts = parse(buffer,"Pp");
+       domain->tmem_stats.succ_pers_gets = parse(buffer,"Gp");
+}
+
 xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags)
 {
 #define DOMAIN_CHUNK_SIZE 256
@@ -232,11 +258,13 @@ xenstat_node *xenstat_get_node(xenstat_h
                        domain->networks = NULL;
                        domain->num_vbds = 0;
                        domain->vbds = NULL;
+                       domain_get_tmem_stats(handle,domain);
 
                        domain++;
                        node->num_domains++;
                }
        } while (new_domains == DOMAIN_CHUNK_SIZE);
+
 
        /* Run all the extra data collectors requested */
        node->flags = 0;
@@ -674,6 +702,40 @@ unsigned long long xenstat_vbd_wr_sects(
        return vbd->wr_sects;
 }
 
+/*
+ * Tmem functions
+ */
+
+xenstat_tmem *xenstat_domain_tmem(xenstat_domain * domain)
+{
+       return &domain->tmem_stats;
+}
+
+/* Get the current number of ephemeral pages */
+unsigned long long xenstat_tmem_curr_eph_pages(xenstat_tmem *tmem)
+{
+       return tmem->curr_eph_pages;
+}
+
+/* Get the number of successful ephemeral gets */
+unsigned long long xenstat_tmem_succ_eph_gets(xenstat_tmem *tmem)
+{
+       return tmem->succ_eph_gets;
+}
+
+/* Get the number of successful persistent puts */
+unsigned long long xenstat_tmem_succ_pers_puts(xenstat_tmem *tmem)
+{
+       return tmem->succ_pers_puts;
+}
+
+/* Get the number of successful persistent gets */
+unsigned long long xenstat_tmem_succ_pers_gets(xenstat_tmem *tmem)
+{
+       return tmem->succ_pers_gets;
+}
+
+
 static char *xenstat_get_domain_name(xenstat_handle *handle, unsigned int 
domain_id)
 {
        char path[80], *vmpath;
diff -r 7f611de6b93c tools/xenstat/libxenstat/src/xenstat.h
--- a/tools/xenstat/libxenstat/src/xenstat.h    Tue Dec 08 14:14:27 2009 +0000
+++ b/tools/xenstat/libxenstat/src/xenstat.h    Tue Dec 08 17:16:29 2009 -0700
@@ -27,6 +27,7 @@ typedef struct xenstat_vcpu xenstat_vcpu
 typedef struct xenstat_vcpu xenstat_vcpu;
 typedef struct xenstat_network xenstat_network;
 typedef struct xenstat_vbd xenstat_vbd;
+typedef struct xenstat_tmem xenstat_tmem;
 
 /* Initialize the xenstat library.  Returns a handle to be used with
  * subsequent calls to the xenstat library, or NULL if an error occurs. */
@@ -132,6 +133,9 @@ xenstat_vbd *xenstat_domain_vbd(xenstat_
 xenstat_vbd *xenstat_domain_vbd(xenstat_domain * domain,
                                    unsigned int vbd);
 
+/* Get the tmem information for a given domain */
+xenstat_tmem *xenstat_domain_tmem(xenstat_domain * domain);
+
 /*
  * VCPU functions - extract information from a xenstat_vcpu
  */
@@ -189,4 +193,12 @@ unsigned long long xenstat_vbd_rd_sects(
 unsigned long long xenstat_vbd_rd_sects(xenstat_vbd * vbd);
 unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd);
 
+/*
+ * Tmem functions - extract tmem information
+ */
+unsigned long long xenstat_tmem_curr_eph_pages(xenstat_tmem *tmem);
+unsigned long long xenstat_tmem_succ_eph_gets(xenstat_tmem *tmem);
+unsigned long long xenstat_tmem_succ_pers_puts(xenstat_tmem *tmem);
+unsigned long long xenstat_tmem_succ_pers_gets(xenstat_tmem *tmem);
+
 #endif /* XENSTAT_H */
diff -r 7f611de6b93c tools/xenstat/libxenstat/src/xenstat_priv.h
--- a/tools/xenstat/libxenstat/src/xenstat_priv.h       Tue Dec 08 14:14:27 
2009 +0000
+++ b/tools/xenstat/libxenstat/src/xenstat_priv.h       Tue Dec 08 17:16:29 
2009 -0700
@@ -52,6 +52,13 @@ struct xenstat_node {
        long freeable_mb;
 };
 
+struct xenstat_tmem {
+       unsigned long long curr_eph_pages;
+       unsigned long long succ_eph_gets;
+       unsigned long long succ_pers_puts;
+       unsigned long long succ_pers_gets;
+};
+
 struct xenstat_domain {
        unsigned int id;
        char *name;
@@ -66,6 +73,7 @@ struct xenstat_domain {
        xenstat_network *networks;      /* Array of length num_networks */
        unsigned int num_vbds;
        xenstat_vbd *vbds;
+       xenstat_tmem tmem_stats;
 };
 
 struct xenstat_vcpu {
diff -r 7f611de6b93c tools/xenstat/xentop/xentop.c
--- a/tools/xenstat/xentop/xentop.c     Tue Dec 08 14:14:27 2009 +0000
+++ b/tools/xenstat/xentop/xentop.c     Tue Dec 08 17:16:29 2009 -0700
@@ -202,6 +202,7 @@ int show_vcpus = 0;
 int show_vcpus = 0;
 int show_networks = 0;
 int show_vbds = 0;
+int show_tmem = 0;
 int repeat_header = 0;
 int show_full_name = 0;
 #define PROMPT_VAL_LEN 80
@@ -353,6 +354,9 @@ static int handle_key(int ch)
                        break;
                case 'b': case 'B':
                        show_vbds ^= 1;
+                       break;
+               case 't': case 'T':
+                       show_tmem ^= 1;
                        break;
                case 'r': case 'R':
                        repeat_header ^= 1;
@@ -889,6 +893,11 @@ void do_bottom_line(void)
                attr_addstr(show_vbds ? COLOR_PAIR(1) : 0, "ds");
                addstr("  ");
 
+               /* tmem */
+               addch(A_REVERSE | 'T');
+               attr_addstr(show_tmem ? COLOR_PAIR(1) : 0, "mem");
+               addstr("  ");
+
 
                /* vcpus */
                addch(A_REVERSE | 'V');
@@ -1018,6 +1027,23 @@ void do_vbd(xenstat_domain *domain)
        }
 }
 
+/* Output all tmem information */
+void do_tmem(xenstat_domain *domain)
+{
+       xenstat_tmem *tmem = xenstat_domain_tmem(domain);
+       unsigned long long curr_eph_pages = xenstat_tmem_curr_eph_pages(tmem);
+       unsigned long long succ_eph_gets = xenstat_tmem_succ_eph_gets(tmem);
+       unsigned long long succ_pers_puts = xenstat_tmem_succ_pers_puts(tmem);
+       unsigned long long succ_pers_gets = xenstat_tmem_succ_pers_gets(tmem);
+
+       if (curr_eph_pages | succ_eph_gets | succ_pers_puts | succ_pers_gets)
+               print("Tmem:  Curr eph pages: %8llu   Succ eph gets: %8llu   "
+                     "Succ pers puts: %8llu   Succ pers gets: %8llu\n",
+                       curr_eph_pages, succ_eph_gets,
+                       succ_pers_puts, succ_pers_gets);
+
+}
+
 static void top(void)
 {
        xenstat_domain **domains;
@@ -1064,6 +1090,8 @@ static void top(void)
                        do_network(domains[i]);
                if (show_vbds)
                        do_vbd(domains[i]);
+               if (show_tmem)
+                       do_tmem(domains[i]);
        }
 
        if (!batch)
@@ -1139,6 +1167,9 @@ int main(int argc, char **argv)
                case 'f':
                        show_full_name = 1;
                        break;
+               case 't':
+                       show_tmem = 1;
+                       break;
                }
        }

Attachment: tmem-xentop2.patch
Description: Binary data

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] tmem/xentop: add useful tmem output to xentop, Dan Magenheimer <=