debuggers.hg

changeset 20649:9e9746e635f9

tmem, xentop: Report a few key per-domain tmem statistics in xentop.

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Dec 09 10:46:11 2009 +0000 (2009-12-09)
parents 18342df0f9dc
children d820a6b813db
files tools/xenstat/libxenstat/src/xenstat.c tools/xenstat/libxenstat/src/xenstat.h tools/xenstat/libxenstat/src/xenstat_priv.h tools/xenstat/xentop/xentop.c
line diff
     1.1 --- a/tools/xenstat/libxenstat/src/xenstat.c	Wed Dec 09 10:44:56 2009 +0000
     1.2 +++ b/tools/xenstat/libxenstat/src/xenstat.c	Wed Dec 09 10:46:11 2009 +0000
     1.3 @@ -131,6 +131,32 @@ void xenstat_uninit(xenstat_handle * han
     1.4  	}
     1.5  }
     1.6  
     1.7 +static inline unsigned long long parse(char *s, char *match)
     1.8 +{
     1.9 +	char *s1 = strstr(s,match);
    1.10 +	unsigned long long ret;
    1.11 +
    1.12 +	if ( s1 == NULL )
    1.13 +		return 0LL;
    1.14 +	s1 += 2;
    1.15 +	if ( *s1++ != ':' )
    1.16 +		return 0LL;
    1.17 +	sscanf(s1,"%llu",&ret);
    1.18 +	return ret;
    1.19 +}
    1.20 +
    1.21 +void domain_get_tmem_stats(xenstat_handle * handle, xenstat_domain * domain)
    1.22 +{
    1.23 +	char buffer[4096];
    1.24 +
    1.25 +	xc_tmem_control(handle->xc_handle,-1,TMEMC_LIST,domain->id,
    1.26 +                        sizeof(buffer),-1,-1,buffer);
    1.27 +	domain->tmem_stats.curr_eph_pages = parse(buffer,"Ec");
    1.28 +	domain->tmem_stats.succ_eph_gets = parse(buffer,"Ge");
    1.29 +	domain->tmem_stats.succ_pers_puts = parse(buffer,"Pp");
    1.30 +	domain->tmem_stats.succ_pers_gets = parse(buffer,"Gp");
    1.31 +}
    1.32 +
    1.33  xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags)
    1.34  {
    1.35  #define DOMAIN_CHUNK_SIZE 256
    1.36 @@ -232,12 +258,14 @@ xenstat_node *xenstat_get_node(xenstat_h
    1.37  			domain->networks = NULL;
    1.38  			domain->num_vbds = 0;
    1.39  			domain->vbds = NULL;
    1.40 +			domain_get_tmem_stats(handle,domain);
    1.41  
    1.42  			domain++;
    1.43  			node->num_domains++;
    1.44  		}
    1.45  	} while (new_domains == DOMAIN_CHUNK_SIZE);
    1.46  
    1.47 +
    1.48  	/* Run all the extra data collectors requested */
    1.49  	node->flags = 0;
    1.50  	for (i = 0; i < NUM_COLLECTORS; i++) {
    1.51 @@ -674,6 +702,40 @@ unsigned long long xenstat_vbd_wr_sects(
    1.52  	return vbd->wr_sects;
    1.53  }
    1.54  
    1.55 +/*
    1.56 + * Tmem functions
    1.57 + */
    1.58 +
    1.59 +xenstat_tmem *xenstat_domain_tmem(xenstat_domain * domain)
    1.60 +{
    1.61 +	return &domain->tmem_stats;
    1.62 +}
    1.63 +
    1.64 +/* Get the current number of ephemeral pages */
    1.65 +unsigned long long xenstat_tmem_curr_eph_pages(xenstat_tmem *tmem)
    1.66 +{
    1.67 +	return tmem->curr_eph_pages;
    1.68 +}
    1.69 +
    1.70 +/* Get the number of successful ephemeral gets */
    1.71 +unsigned long long xenstat_tmem_succ_eph_gets(xenstat_tmem *tmem)
    1.72 +{
    1.73 +	return tmem->succ_eph_gets;
    1.74 +}
    1.75 +
    1.76 +/* Get the number of successful persistent puts */
    1.77 +unsigned long long xenstat_tmem_succ_pers_puts(xenstat_tmem *tmem)
    1.78 +{
    1.79 +	return tmem->succ_pers_puts;
    1.80 +}
    1.81 +
    1.82 +/* Get the number of successful persistent gets */
    1.83 +unsigned long long xenstat_tmem_succ_pers_gets(xenstat_tmem *tmem)
    1.84 +{
    1.85 +	return tmem->succ_pers_gets;
    1.86 +}
    1.87 +
    1.88 +
    1.89  static char *xenstat_get_domain_name(xenstat_handle *handle, unsigned int domain_id)
    1.90  {
    1.91  	char path[80], *vmpath;
     2.1 --- a/tools/xenstat/libxenstat/src/xenstat.h	Wed Dec 09 10:44:56 2009 +0000
     2.2 +++ b/tools/xenstat/libxenstat/src/xenstat.h	Wed Dec 09 10:46:11 2009 +0000
     2.3 @@ -27,6 +27,7 @@ typedef struct xenstat_node xenstat_node
     2.4  typedef struct xenstat_vcpu xenstat_vcpu;
     2.5  typedef struct xenstat_network xenstat_network;
     2.6  typedef struct xenstat_vbd xenstat_vbd;
     2.7 +typedef struct xenstat_tmem xenstat_tmem;
     2.8  
     2.9  /* Initialize the xenstat library.  Returns a handle to be used with
    2.10   * subsequent calls to the xenstat library, or NULL if an error occurs. */
    2.11 @@ -132,6 +133,9 @@ unsigned int xenstat_domain_num_vbds(xen
    2.12  xenstat_vbd *xenstat_domain_vbd(xenstat_domain * domain,
    2.13  				    unsigned int vbd);
    2.14  
    2.15 +/* Get the tmem information for a given domain */
    2.16 +xenstat_tmem *xenstat_domain_tmem(xenstat_domain * domain);
    2.17 +
    2.18  /*
    2.19   * VCPU functions - extract information from a xenstat_vcpu
    2.20   */
    2.21 @@ -189,4 +193,12 @@ unsigned long long xenstat_vbd_wr_reqs(x
    2.22  unsigned long long xenstat_vbd_rd_sects(xenstat_vbd * vbd);
    2.23  unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd);
    2.24  
    2.25 +/*
    2.26 + * Tmem functions - extract tmem information
    2.27 + */
    2.28 +unsigned long long xenstat_tmem_curr_eph_pages(xenstat_tmem *tmem);
    2.29 +unsigned long long xenstat_tmem_succ_eph_gets(xenstat_tmem *tmem);
    2.30 +unsigned long long xenstat_tmem_succ_pers_puts(xenstat_tmem *tmem);
    2.31 +unsigned long long xenstat_tmem_succ_pers_gets(xenstat_tmem *tmem);
    2.32 +
    2.33  #endif /* XENSTAT_H */
     3.1 --- a/tools/xenstat/libxenstat/src/xenstat_priv.h	Wed Dec 09 10:44:56 2009 +0000
     3.2 +++ b/tools/xenstat/libxenstat/src/xenstat_priv.h	Wed Dec 09 10:46:11 2009 +0000
     3.3 @@ -52,6 +52,13 @@ struct xenstat_node {
     3.4  	long freeable_mb;
     3.5  };
     3.6  
     3.7 +struct xenstat_tmem {
     3.8 +	unsigned long long curr_eph_pages;
     3.9 +	unsigned long long succ_eph_gets;
    3.10 +	unsigned long long succ_pers_puts;
    3.11 +	unsigned long long succ_pers_gets;
    3.12 +};
    3.13 +
    3.14  struct xenstat_domain {
    3.15  	unsigned int id;
    3.16  	char *name;
    3.17 @@ -66,6 +73,7 @@ struct xenstat_domain {
    3.18  	xenstat_network *networks;	/* Array of length num_networks */
    3.19  	unsigned int num_vbds;
    3.20  	xenstat_vbd *vbds;
    3.21 +	xenstat_tmem tmem_stats;
    3.22  };
    3.23  
    3.24  struct xenstat_vcpu {
     4.1 --- a/tools/xenstat/xentop/xentop.c	Wed Dec 09 10:44:56 2009 +0000
     4.2 +++ b/tools/xenstat/xentop/xentop.c	Wed Dec 09 10:46:11 2009 +0000
     4.3 @@ -202,6 +202,7 @@ unsigned int iterations = 0;
     4.4  int show_vcpus = 0;
     4.5  int show_networks = 0;
     4.6  int show_vbds = 0;
     4.7 +int show_tmem = 0;
     4.8  int repeat_header = 0;
     4.9  int show_full_name = 0;
    4.10  #define PROMPT_VAL_LEN 80
    4.11 @@ -354,6 +355,9 @@ static int handle_key(int ch)
    4.12  		case 'b': case 'B':
    4.13  			show_vbds ^= 1;
    4.14  			break;
    4.15 +		case 't': case 'T':
    4.16 +			show_tmem ^= 1;
    4.17 +			break;
    4.18  		case 'r': case 'R':
    4.19  			repeat_header ^= 1;
    4.20  			break;
    4.21 @@ -889,6 +893,11 @@ void do_bottom_line(void)
    4.22  		attr_addstr(show_vbds ? COLOR_PAIR(1) : 0, "ds");
    4.23  		addstr("  ");
    4.24  
    4.25 +		/* tmem */
    4.26 +		addch(A_REVERSE | 'T');
    4.27 +		attr_addstr(show_tmem ? COLOR_PAIR(1) : 0, "mem");
    4.28 +		addstr("  ");
    4.29 +
    4.30  
    4.31  		/* vcpus */
    4.32  		addch(A_REVERSE | 'V');
    4.33 @@ -1018,6 +1027,23 @@ void do_vbd(xenstat_domain *domain)
    4.34  	}
    4.35  }
    4.36  
    4.37 +/* Output all tmem information */
    4.38 +void do_tmem(xenstat_domain *domain)
    4.39 +{
    4.40 +	xenstat_tmem *tmem = xenstat_domain_tmem(domain);
    4.41 +	unsigned long long curr_eph_pages = xenstat_tmem_curr_eph_pages(tmem);
    4.42 +	unsigned long long succ_eph_gets = xenstat_tmem_succ_eph_gets(tmem);
    4.43 +	unsigned long long succ_pers_puts = xenstat_tmem_succ_pers_puts(tmem);
    4.44 +	unsigned long long succ_pers_gets = xenstat_tmem_succ_pers_gets(tmem);
    4.45 +
    4.46 +	if (curr_eph_pages | succ_eph_gets | succ_pers_puts | succ_pers_gets)
    4.47 +		print("Tmem:  Curr eph pages: %8llu   Succ eph gets: %8llu   "
    4.48 +	              "Succ pers puts: %8llu   Succ pers gets: %8llu\n",
    4.49 +			curr_eph_pages, succ_eph_gets,
    4.50 +			succ_pers_puts, succ_pers_gets);
    4.51 +
    4.52 +}
    4.53 +
    4.54  static void top(void)
    4.55  {
    4.56  	xenstat_domain **domains;
    4.57 @@ -1064,6 +1090,8 @@ static void top(void)
    4.58  			do_network(domains[i]);
    4.59  		if (show_vbds)
    4.60  			do_vbd(domains[i]);
    4.61 +		if (show_tmem)
    4.62 +			do_tmem(domains[i]);
    4.63  	}
    4.64  
    4.65  	if (!batch)
    4.66 @@ -1139,6 +1167,9 @@ int main(int argc, char **argv)
    4.67  		case 'f':
    4.68  			show_full_name = 1;
    4.69  			break;
    4.70 +		case 't':
    4.71 +			show_tmem = 1;
    4.72 +			break;
    4.73  		}
    4.74  	}
    4.75