From: "Satoshi Uchida" Subject: [PATCH 2/2][Resend] Output Virtual Block Device requests information for xentop. ver.2 Date: Fri, 30 Jun 2006 17:06:48 +0900 Message-ID: <003f01c69c1c$22c48680$4c87380a@ad.spf.cl.nec.co.jp> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0040_01C69C67.92AC2E80" 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_0040_01C69C67.92AC2E80 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_0040_01C69C67.92AC2E80 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 # User Satoshi UCHIDA # Node ID 763f043712421a8848a1a1d1013c0e67a28f8932 # Parent e9f165338a9325b03c56d4d278de42598bd335e6 [XENTOP]Add VBD information. display VBD information at xentop. By put 'b' key, display each VBD information in detail. Signed-off-by: Satoshi UCHIDA diff -r 43dda746e4ca -r d295ab4b8be8 tools/xenstat/xentop/xentop.c --- a/tools/xenstat/xentop/xentop.c Wed Jun 28 22:34:37 2006 +0900 +++ b/tools/xenstat/xentop/xentop.c Wed Jun 28 22:36:41 2006 +0900 @@ -27,6 +27,7 @@ #include #include #include +#include =20 #include =20 @@ -65,6 +66,7 @@ static int compare(unsigned long long, u static int compare(unsigned long long, unsigned long long); static int compare_domains(xenstat_domain **, xenstat_domain **); static unsigned long long tot_net_bytes( xenstat_domain *, int); +static unsigned long long tot_vbd_reqs( xenstat_domain *, int); =20 /* Field functions */ static int compare_state(xenstat_domain *domain1, xenstat_domain = *domain2); @@ -91,6 +93,15 @@ static void print_ssid(xenstat_domain *d static void print_ssid(xenstat_domain *domain); static int compare_name(xenstat_domain *domain1, xenstat_domain = *domain2); static void print_name(xenstat_domain *domain); +static int compare_vbds(xenstat_domain *domain1, xenstat_domain = *domain2); +static void print_vbds(xenstat_domain *domain); +static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain = *domain2); +static void print_vbd_oo(xenstat_domain *domain); +static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain = *domain2); +static void print_vbd_rd(xenstat_domain *domain); +static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain = *domain2); +static void print_vbd_wr(xenstat_domain *domain); + =20 /* Section printing functions */ static void do_summary(void); @@ -99,6 +110,7 @@ static void do_domain(xenstat_domain *); static void do_domain(xenstat_domain *); static void do_vcpu(xenstat_domain *); static void do_network(xenstat_domain *); +static void do_vbd(xenstat_domain *); static void top(void); =20 /* Field types */ @@ -116,6 +128,10 @@ typedef enum field_id { FIELD_NETS, FIELD_NET_TX, FIELD_NET_RX, + FIELD_VBDS, + FIELD_VBD_OO, + FIELD_VBD_RD, + FIELD_VBD_WR, FIELD_SSID } field_id; =20 @@ -140,7 +156,11 @@ field fields[] =3D { { FIELD_NETS, "NETS", 4, compare_nets, print_nets }, { FIELD_NET_TX, "NETTX(k)", 8, compare_net_tx, print_net_tx }, { FIELD_NET_RX, "NETRX(k)", 8, compare_net_rx, print_net_rx }, - { FIELD_SSID, "SSID", 4, compare_ssid, print_ssid } + { FIELD_NET_RX, "VBDS", 8, compare_vbds, print_vbds }, + { FIELD_NET_RX, "VBD_OO", 8, compare_vbd_oo, print_vbd_oo }, + { FIELD_NET_RX, "VBD_RD", 8, compare_vbd_rd, print_vbd_rd }, + { FIELD_NET_RX, "VBD_WR", 8, compare_vbd_wr, print_vbd_wr }, + { FIELD_SSID, "SSID", 4, compare_ssid, print_ssid = } }; =20 const unsigned int NUM_FIELDS =3D sizeof(fields)/sizeof(field); @@ -155,6 +175,7 @@ unsigned int delay =3D 3; unsigned int delay =3D 3; int show_vcpus =3D 0; int show_networks =3D 0; +int show_vbds =3D 0; int repeat_header =3D 0; #define PROMPT_VAL_LEN 80 char *prompt =3D NULL; @@ -177,6 +198,7 @@ static void usage(const char *program) "-V, --version output version information and exit\n" "-d, --delay=3DSECONDS seconds between updates (default 3)\n" "-n, --networks output vif network data\n" + "-b, --vbds output vbd block device data\n" "-r, --repeat-header repeat table header before each domain\n" "-v, --vcpus output vcpu data\n" "\n" XENTOP_BUGSTO, @@ -278,6 +300,9 @@ static int handle_key(int ch) switch(ch) { case 'n': case 'N': show_networks ^=3D 1; + break; + case 'b': case 'B': + show_vbds ^=3D 1; break; case 'r': case 'R': repeat_header ^=3D 1; @@ -574,6 +599,96 @@ static unsigned long long tot_net_bytes( return total; } =20 +/* Compares number of virtual block devices of two domains, + returning -1,0,1 for * <,=3D,> */ +static int compare_vbds(xenstat_domain *domain1, xenstat_domain = *domain2) +{ + return -compare(xenstat_domain_num_vbds(domain1), + xenstat_domain_num_vbds(domain2)); +} + +/* Prints number of virtual block devices statistic */ +static void print_vbds(xenstat_domain *domain) +{ + print("%4u", xenstat_domain_num_vbds(domain)); +} + +/* Compares number of total VBD OO requests of two domains, + returning -1,0,1 * for <,=3D,> */ +static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain = *domain2) +{ + return -compare(tot_vbd_reqs(domain1, FIELD_VBD_OO), + tot_vbd_reqs(domain2, FIELD_VBD_OO)); +} + +/* Prints number of total VBD OO requests statistic */ +static void print_vbd_oo(xenstat_domain *domain) +{ + print("%8llu", tot_vbd_reqs(domain, FIELD_VBD_OO)); +} + +/* Compares number of total VBD READ requests of two domains, + returning -1,0,1 * for <,=3D,> */ +static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain = *domain2) +{ + return -compare(tot_vbd_reqs(domain1, FIELD_VBD_RD), + tot_vbd_reqs(domain2, FIELD_VBD_RD)); +} + +/* Prints number of total VBD READ requests statistic */ +static void print_vbd_rd(xenstat_domain *domain) +{ + print("%8llu", tot_vbd_reqs(domain, FIELD_VBD_RD)); +} + +/* Compares number of total VBD WRITE requests of two domains, + returning -1,0,1 * for <,=3D,> */ +static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain = *domain2) +{ + return -compare(tot_vbd_reqs(domain1,FIELD_VBD_WR), + tot_vbd_reqs(domain2,FIELD_VBD_WR)); +} + +/* Prints number of total VBD WRITE requests statistic */ +static void print_vbd_wr(xenstat_domain *domain) +{ + print("%8llu", tot_vbd_reqs(domain,FIELD_VBD_WR)); +} + +/* Gets number of total VBD requests statistic,=20 + * if flag is FIELD_VBD_OO, then OO requests, + * if flag is FIELD_VBD_RD, then READ requests and + * if flag is FIELD_VBD_WR, then WRITE requests. + */ +static unsigned long long tot_vbd_reqs(xenstat_domain *domain, int = flag) +{ + int i =3D 0; + xenstat_vbd *vbd; + unsigned num_vbds =3D 0; + unsigned long long total =3D 0; +=09 + num_vbds =3D xenstat_domain_num_vbds(domain); +=09 + for ( i=3D0 ; i < num_vbds ; i++) { + vbd =3D xenstat_domain_vbd(domain,i); + switch(flag) { + case FIELD_VBD_OO: + total +=3D xenstat_vbd_oo_reqs(vbd); + break; + case FIELD_VBD_RD: + total +=3D xenstat_vbd_rd_reqs(vbd); + break; + case FIELD_VBD_WR: + total +=3D xenstat_vbd_wr_reqs(vbd); + break; + default: + break; + } + } +=09 + return total; +} + /* Compares security id (ssid) of two domains, returning -1,0,1 for = <,=3D,> */ static int compare_ssid(xenstat_domain *domain1, xenstat_domain = *domain2) { @@ -669,6 +784,13 @@ void do_bottom_line(void) addch(A_REVERSE | 'N'); attr_addstr(show_networks ? COLOR_PAIR(1) : 0, "etworks"); addstr(" "); + =09 + /* VBDs */ + attr_addstr(show_vbds ? COLOR_PAIR(1) : 0, "v"); + addch(A_REVERSE | 'B'); + attr_addstr(show_vbds ? COLOR_PAIR(1) : 0, "ds"); + addstr(" "); + =20 /* vcpus */ addch(A_REVERSE | 'V'); @@ -758,6 +880,28 @@ void do_network(xenstat_domain *domain) } } =20 + +/* Output all VBD information */ +void do_vbd(xenstat_domain *domain) +{ + int i =3D 0; + xenstat_vbd *vbd; + unsigned num_vbds =3D 0; + + num_vbds =3D xenstat_domain_num_vbds(domain); + + for (i=3D0 ; i< num_vbds; i++) { + vbd =3D xenstat_domain_vbd(domain,i); + =09 + print("VBD %4u [%2x:%2x] OO: %8llu RD: %8llu WR: %8llu\n", + xenstat_vbd_dev(vbd), + MAJOR(xenstat_vbd_dev(vbd)), MINOR(xenstat_vbd_dev(vbd)), + xenstat_vbd_oo_reqs(vbd), + xenstat_vbd_rd_reqs(vbd), + xenstat_vbd_wr_reqs(vbd)); + } +} + static void top(void) { xenstat_domain **domains; @@ -801,6 +945,8 @@ static void top(void) do_vcpu(domains[i]); if (show_networks) do_network(domains[i]); + if (show_vbds) + do_vbd(domains[i]); } =20 do_bottom_line(); @@ -815,12 +961,13 @@ int main(int argc, char **argv) { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { "networks", no_argument, NULL, 'n' }, + { "vbds", no_argument, NULL, 'b' }, { "repeat-header", no_argument, NULL, 'r' }, { "vcpus", no_argument, NULL, 'v' }, { "delay", required_argument, NULL, 'd' }, { 0, 0, 0, 0 }, }; - const char *sopts =3D "hVbnvd:"; + const char *sopts =3D "hVbnrvd:"; =20 if (atexit(cleanup) !=3D 0) fail("Failed to install cleanup handler.\n"); @@ -838,6 +985,9 @@ int main(int argc, char **argv) case 'n': show_networks =3D 1; break; + case 'b': + show_vbds =3D 1; + break; case 'r': repeat_header =3D 1; break; ------=_NextPart_000_0040_01C69C67.92AC2E80 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_0040_01C69C67.92AC2E80--