diff options
-rw-r--r-- | tools/xenstat/libxenstat/src/xenstat.c | 62 | ||||
-rw-r--r-- | tools/xenstat/libxenstat/src/xenstat.h | 12 | ||||
-rw-r--r-- | tools/xenstat/libxenstat/src/xenstat_priv.h | 8 | ||||
-rw-r--r-- | tools/xenstat/xentop/xentop.c | 31 |
4 files changed, 113 insertions, 0 deletions
diff --git a/tools/xenstat/libxenstat/src/xenstat.c b/tools/xenstat/libxenstat/src/xenstat.c index 67d861fd55..6396f5959d 100644 --- a/tools/xenstat/libxenstat/src/xenstat.c +++ b/tools/xenstat/libxenstat/src/xenstat.c @@ -131,6 +131,32 @@ void xenstat_uninit(xenstat_handle * handle) } } +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,12 +258,14 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags) 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; for (i = 0; i < NUM_COLLECTORS; i++) { @@ -674,6 +702,40 @@ unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd) 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 --git a/tools/xenstat/libxenstat/src/xenstat.h b/tools/xenstat/libxenstat/src/xenstat.h index 1da354b22a..47ec60e14d 100644 --- a/tools/xenstat/libxenstat/src/xenstat.h +++ b/tools/xenstat/libxenstat/src/xenstat.h @@ -27,6 +27,7 @@ typedef struct xenstat_node xenstat_node; 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 @@ unsigned int xenstat_domain_num_vbds(xenstat_domain *); 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_wr_reqs(xenstat_vbd * vbd); 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 --git a/tools/xenstat/libxenstat/src/xenstat_priv.h b/tools/xenstat/libxenstat/src/xenstat_priv.h index af955014ae..81beec1d8e 100644 --- a/tools/xenstat/libxenstat/src/xenstat_priv.h +++ b/tools/xenstat/libxenstat/src/xenstat_priv.h @@ -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 --git a/tools/xenstat/xentop/xentop.c b/tools/xenstat/xentop/xentop.c index af9ebc8676..b890829459 100644 --- a/tools/xenstat/xentop/xentop.c +++ b/tools/xenstat/xentop/xentop.c @@ -202,6 +202,7 @@ unsigned int iterations = 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 @@ -354,6 +355,9 @@ static int handle_key(int ch) case 'b': case 'B': show_vbds ^= 1; break; + case 't': case 'T': + show_tmem ^= 1; + break; case 'r': case 'R': repeat_header ^= 1; break; @@ -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; } } |