From: "Satoshi Uchida" Subject: [PATCH 2/2] Output Virtual Block Device requests information for xentop Date: Wed, 28 Jun 2006 22:49:36 +0900 Message-ID: <007201c69ab9$b15a9a10$4c87380a@ad.spf.cl.nec.co.jp> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0073_01C69B05.21424210" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. ------=_NextPart_000_0073_01C69B05.21424210 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable =20 This patch adds VBD statistical information into xentop. Our new xentop collects I/O requests from sysfs and displays them. This is an example output of the new xentop in the case of 4 VMs. xentop - 22:26:21 Xen 3.0-unstable 2 domains: 1 running, 1 blocked, 0 paused, 0 crashed, 0 dying, 0 = shutdown Mem: 2620476k total, 2128336k used, 492140k free CPUs: 2 @ 2992MHz NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) = MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS VBD_OO VBD_RD = VBD_WR SSID Domain-0 -----r 279 31.4 1048628 40.0 no limit = n/a 2 8 53668 3761 0 0 0 0 0 VM1 --b--- 14 0.1 1048352 40.0 1048576 = 40.0 2 1 1 645 1 0 1435 733 0 Delay Networks vBds VCPUs Repeat header Sort order Quit As compared with the traditional xentop, new statistical information = (VBDS, VBD_OO, VBD_RD and VBD_WR) is added. In detail mode, outputs of xentop is as follows. xentop - 22:26:39 Xen 3.0-unstable 2 domains: 1 running, 1 blocked, 0 paused, 0 crashed, 0 dying, 0 = shutdown Mem: 2620476k total, 2128336k used, 492140k free CPUs: 2 @ 2992MHz NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) = MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS VBD_OO VBD_RD = VBD_WR SSID Domain-0 -----r 284 17.4 1048580 40.0 no limit = n/a 2 8 56148 3885 0 0 0 0 0 VM1 --b--- 14 0.0 1048400 40.0 1048576 = 40.0 2 1 1 662 1 0 1435 736 0 VBD 2049 [ 8: 1] OO: 0 RD: 1435 WR: 736 Delay Networks vBds VCPUs Repeat header Sort order Quit Information about each VBD is displayed under a line of corresponding = domain. This patch is practically no change from previous patch. Only the location of code is changed, and insert code which transfers = from dev information to major and minor information. Thanks, Satoshi UCHIDA ------=_NextPart_000_0073_01C69B05.21424210 Content-Type: application/octet-stream; name="Add_VBD_info_to_xentop.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="Add_VBD_info_to_xentop.patch" # HG changeset patch=0A= # User Satoshi UCHIDA =0A= # Node ID 763f043712421a8848a1a1d1013c0e67a28f8932=0A= # Parent e9f165338a9325b03c56d4d278de42598bd335e6=0A= Add VBD information into xentop.=0A= =0A= display VBD information at xentop.=0A= By put 'b' key, display each VBD information in detail.=0A= =0A= Signed-off-by: Satoshi UCHIDA =0A= =0A= diff -r 43dda746e4ca -r d295ab4b8be8 tools/xenstat/xentop/xentop.c=0A= --- a/tools/xenstat/xentop/xentop.c Wed Jun 28 22:34:37 2006 +0900=0A= +++ b/tools/xenstat/xentop/xentop.c Wed Jun 28 22:36:41 2006 +0900=0A= @@ -27,6 +27,7 @@=0A= #include =0A= #include =0A= #include =0A= +#include =0A= =0A= #include =0A= =0A= @@ -65,6 +66,7 @@ static int compare(unsigned long long, u=0A= static int compare(unsigned long long, unsigned long long);=0A= static int compare_domains(xenstat_domain **, xenstat_domain **);=0A= static unsigned long long tot_net_bytes( xenstat_domain *, int);=0A= +static unsigned long long tot_vbd_reqs( xenstat_domain *, int);=0A= =0A= /* Field functions */=0A= static int compare_state(xenstat_domain *domain1, xenstat_domain = *domain2);=0A= @@ -91,6 +93,15 @@ static void print_ssid(xenstat_domain *d=0A= static void print_ssid(xenstat_domain *domain);=0A= static int compare_name(xenstat_domain *domain1, xenstat_domain = *domain2);=0A= static void print_name(xenstat_domain *domain);=0A= +static int compare_vbds(xenstat_domain *domain1, xenstat_domain = *domain2);=0A= +static void print_vbds(xenstat_domain *domain);=0A= +static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain = *domain2);=0A= +static void print_vbd_oo(xenstat_domain *domain);=0A= +static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain = *domain2);=0A= +static void print_vbd_rd(xenstat_domain *domain);=0A= +static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain = *domain2);=0A= +static void print_vbd_wr(xenstat_domain *domain);=0A= +=0A= =0A= /* Section printing functions */=0A= static void do_summary(void);=0A= @@ -99,6 +110,7 @@ static void do_domain(xenstat_domain *);=0A= static void do_domain(xenstat_domain *);=0A= static void do_vcpu(xenstat_domain *);=0A= static void do_network(xenstat_domain *);=0A= +static void do_vbd(xenstat_domain *);=0A= static void top(void);=0A= =0A= /* Field types */=0A= @@ -116,6 +128,10 @@ typedef enum field_id {=0A= FIELD_NETS,=0A= FIELD_NET_TX,=0A= FIELD_NET_RX,=0A= + FIELD_VBDS,=0A= + FIELD_VBD_OO,=0A= + FIELD_VBD_RD,=0A= + FIELD_VBD_WR,=0A= FIELD_SSID=0A= } field_id;=0A= =0A= @@ -140,7 +156,11 @@ field fields[] =3D {=0A= { FIELD_NETS, "NETS", 4, compare_nets, print_nets },=0A= { FIELD_NET_TX, "NETTX(k)", 8, compare_net_tx, print_net_tx },=0A= { FIELD_NET_RX, "NETRX(k)", 8, compare_net_rx, print_net_rx },=0A= - { FIELD_SSID, "SSID", 4, compare_ssid, print_ssid }=0A= + { FIELD_NET_RX, "VBDS", 8, compare_vbds, print_vbds },=0A= + { FIELD_NET_RX, "VBD_OO", 8, compare_vbd_oo, print_vbd_oo },=0A= + { FIELD_NET_RX, "VBD_RD", 8, compare_vbd_rd, print_vbd_rd },=0A= + { FIELD_NET_RX, "VBD_WR", 8, compare_vbd_wr, print_vbd_wr },=0A= + { FIELD_SSID, "SSID", 4, compare_ssid, print_ssid = }=0A= };=0A= =0A= const unsigned int NUM_FIELDS =3D sizeof(fields)/sizeof(field);=0A= @@ -155,6 +175,7 @@ unsigned int delay =3D 3;=0A= unsigned int delay =3D 3;=0A= int show_vcpus =3D 0;=0A= int show_networks =3D 0;=0A= +int show_vbds =3D 0;=0A= int repeat_header =3D 0;=0A= #define PROMPT_VAL_LEN 80=0A= char *prompt =3D NULL;=0A= @@ -177,6 +198,7 @@ static void usage(const char *program)=0A= "-V, --version output version information and exit\n"=0A= "-d, --delay=3DSECONDS seconds between updates (default 3)\n"=0A= "-n, --networks output vif network data\n"=0A= + "-b, --vbds output vbd block device data\n"=0A= "-r, --repeat-header repeat table header before each domain\n"=0A= "-v, --vcpus output vcpu data\n"=0A= "\n" XENTOP_BUGSTO,=0A= @@ -278,6 +300,9 @@ static int handle_key(int ch)=0A= switch(ch) {=0A= case 'n': case 'N':=0A= show_networks ^=3D 1;=0A= + break;=0A= + case 'b': case 'B':=0A= + show_vbds ^=3D 1;=0A= break;=0A= case 'r': case 'R':=0A= repeat_header ^=3D 1;=0A= @@ -574,6 +599,96 @@ static unsigned long long tot_net_bytes(=0A= return total;=0A= }=0A= =0A= +/* Compares number of virtual block devices of two domains,=0A= + returning -1,0,1 for * <,=3D,> */=0A= +static int compare_vbds(xenstat_domain *domain1, xenstat_domain = *domain2)=0A= +{=0A= + return -compare(xenstat_domain_num_vbds(domain1),=0A= + xenstat_domain_num_vbds(domain2));=0A= +}=0A= +=0A= +/* Prints number of virtual block devices statistic */=0A= +static void print_vbds(xenstat_domain *domain)=0A= +{=0A= + print("%4u", xenstat_domain_num_vbds(domain));=0A= +}=0A= +=0A= +/* Compares number of total VBD OO requests of two domains,=0A= + returning -1,0,1 * for <,=3D,> */=0A= +static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain = *domain2)=0A= +{=0A= + return -compare(tot_vbd_reqs(domain1, FIELD_VBD_OO),=0A= + tot_vbd_reqs(domain2, FIELD_VBD_OO));=0A= +}=0A= +=0A= +/* Prints number of total VBD OO requests statistic */=0A= +static void print_vbd_oo(xenstat_domain *domain)=0A= +{=0A= + print("%8llu", tot_vbd_reqs(domain, FIELD_VBD_OO));=0A= +}=0A= +=0A= +/* Compares number of total VBD READ requests of two domains,=0A= + returning -1,0,1 * for <,=3D,> */=0A= +static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain = *domain2)=0A= +{=0A= + return -compare(tot_vbd_reqs(domain1, FIELD_VBD_RD),=0A= + tot_vbd_reqs(domain2, FIELD_VBD_RD));=0A= +}=0A= +=0A= +/* Prints number of total VBD READ requests statistic */=0A= +static void print_vbd_rd(xenstat_domain *domain)=0A= +{=0A= + print("%8llu", tot_vbd_reqs(domain, FIELD_VBD_RD));=0A= +}=0A= +=0A= +/* Compares number of total VBD WRITE requests of two domains,=0A= + returning -1,0,1 * for <,=3D,> */=0A= +static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain = *domain2)=0A= +{=0A= + return -compare(tot_vbd_reqs(domain1,FIELD_VBD_WR),=0A= + tot_vbd_reqs(domain2,FIELD_VBD_WR));=0A= +}=0A= +=0A= +/* Prints number of total VBD WRITE requests statistic */=0A= +static void print_vbd_wr(xenstat_domain *domain)=0A= +{=0A= + print("%8llu", tot_vbd_reqs(domain,FIELD_VBD_WR));=0A= +}=0A= +=0A= +/* Gets number of total VBD requests statistic, =0A= + * if flag is FIELD_VBD_OO, then OO requests,=0A= + * if flag is FIELD_VBD_RD, then READ requests and=0A= + * if flag is FIELD_VBD_WR, then WRITE requests.=0A= + */=0A= +static unsigned long long tot_vbd_reqs(xenstat_domain *domain, int flag)=0A= +{=0A= + int i =3D 0;=0A= + xenstat_vbd *vbd;=0A= + unsigned num_vbds =3D 0;=0A= + unsigned long long total =3D 0;=0A= + =0A= + num_vbds =3D xenstat_domain_num_vbds(domain);=0A= + =0A= + for ( i=3D0 ; i < num_vbds ; i++) {=0A= + vbd =3D xenstat_domain_vbd(domain,i);=0A= + switch(flag) {=0A= + case FIELD_VBD_OO:=0A= + total +=3D xenstat_vbd_oo_reqs(vbd);=0A= + break;=0A= + case FIELD_VBD_RD:=0A= + total +=3D xenstat_vbd_rd_reqs(vbd);=0A= + break;=0A= + case FIELD_VBD_WR:=0A= + total +=3D xenstat_vbd_wr_reqs(vbd);=0A= + break;=0A= + default:=0A= + break;=0A= + }=0A= + }=0A= + =0A= + return total;=0A= +}=0A= +=0A= /* Compares security id (ssid) of two domains, returning -1,0,1 for = <,=3D,> */=0A= static int compare_ssid(xenstat_domain *domain1, xenstat_domain = *domain2)=0A= {=0A= @@ -669,6 +784,13 @@ void do_bottom_line(void)=0A= addch(A_REVERSE | 'N');=0A= attr_addstr(show_networks ? COLOR_PAIR(1) : 0, "etworks");=0A= addstr(" ");=0A= + =0A= + /* VBDs */=0A= + attr_addstr(show_vbds ? COLOR_PAIR(1) : 0, "v");=0A= + addch(A_REVERSE | 'B');=0A= + attr_addstr(show_vbds ? COLOR_PAIR(1) : 0, "ds");=0A= + addstr(" ");=0A= +=0A= =0A= /* vcpus */=0A= addch(A_REVERSE | 'V');=0A= @@ -758,6 +880,28 @@ void do_network(xenstat_domain *domain)=0A= }=0A= }=0A= =0A= +=0A= +/* Output all VBD information */=0A= +void do_vbd(xenstat_domain *domain)=0A= +{=0A= + int i =3D 0;=0A= + xenstat_vbd *vbd;=0A= + unsigned num_vbds =3D 0;=0A= +=0A= + num_vbds =3D xenstat_domain_num_vbds(domain);=0A= +=0A= + for (i=3D0 ; i< num_vbds; i++) {=0A= + vbd =3D xenstat_domain_vbd(domain,i);=0A= + =0A= + print("VBD %4u [%2x:%2x] OO: %8llu RD: %8llu WR: %8llu\n",=0A= + xenstat_vbd_dev(vbd),=0A= + MAJOR(xenstat_vbd_dev(vbd)), MINOR(xenstat_vbd_dev(vbd)),=0A= + xenstat_vbd_oo_reqs(vbd),=0A= + xenstat_vbd_rd_reqs(vbd),=0A= + xenstat_vbd_wr_reqs(vbd));=0A= + }=0A= +}=0A= +=0A= static void top(void)=0A= {=0A= xenstat_domain **domains;=0A= @@ -801,6 +945,8 @@ static void top(void)=0A= do_vcpu(domains[i]);=0A= if (show_networks)=0A= do_network(domains[i]);=0A= + if (show_vbds)=0A= + do_vbd(domains[i]);=0A= }=0A= =0A= do_bottom_line();=0A= @@ -815,12 +961,13 @@ int main(int argc, char **argv)=0A= { "help", no_argument, NULL, 'h' },=0A= { "version", no_argument, NULL, 'V' },=0A= { "networks", no_argument, NULL, 'n' },=0A= + { "vbds", no_argument, NULL, 'b' },=0A= { "repeat-header", no_argument, NULL, 'r' },=0A= { "vcpus", no_argument, NULL, 'v' },=0A= { "delay", required_argument, NULL, 'd' },=0A= { 0, 0, 0, 0 },=0A= };=0A= - const char *sopts =3D "hVbnvd:";=0A= + const char *sopts =3D "hVbnrvd:";=0A= =0A= if (atexit(cleanup) !=3D 0)=0A= fail("Failed to install cleanup handler.\n");=0A= @@ -838,6 +985,9 @@ int main(int argc, char **argv)=0A= case 'n':=0A= show_networks =3D 1;=0A= break;=0A= + case 'b':=0A= + show_vbds =3D 1;=0A= + break;=0A= case 'r':=0A= repeat_header =3D 1;=0A= break;=0A= ------=_NextPart_000_0073_01C69B05.21424210 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ------=_NextPart_000_0073_01C69B05.21424210--