All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yang, Xiaowei" <xiaowei.yang@intel.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: [PATCH] Add two more VBD statistics into Xentop
Date: Thu, 05 Nov 2009 18:18:01 +0800	[thread overview]
Message-ID: <4AF2A659.6060300@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 272 bytes --]

In addition to VBD read/write request#, add VBD read/write sector# also. It 
makes VBD throughput observation easier. As the method to get such info is OS 
dependent, just Linux version code is added.

Signed-off-by: Yang Xiaowei <xiaowei.yang@intel.com>

Thanks,
xiaowei

[-- Attachment #2: xentop.patch --]
[-- Type: text/x-patch, Size: 8706 bytes --]

diff -r 059c01d69a08 tools/xenstat/libxenstat/src/xenstat.c
--- a/tools/xenstat/libxenstat/src/xenstat.c	Thu Oct 29 14:48:28 2009 +0000
+++ b/tools/xenstat/libxenstat/src/xenstat.c	Thu Nov 05 09:28:00 2009 +0800
@@ -653,6 +653,18 @@
 	return vbd->wr_reqs;
 }
 
+/* Get the number of READ sectors */
+unsigned long long xenstat_vbd_rd_sects(xenstat_vbd * vbd)
+{
+	return vbd->rd_sects;
+}
+
+/* Get the number of WRITE sectors */
+unsigned long long xenstat_vbd_wr_sects(xenstat_vbd * vbd)
+{
+	return vbd->wr_sects;
+}
+
 static char *xenstat_get_domain_name(xenstat_handle *handle, unsigned int domain_id)
 {
 	char path[80], *vmpath;
diff -r 059c01d69a08 tools/xenstat/libxenstat/src/xenstat.h
--- a/tools/xenstat/libxenstat/src/xenstat.h	Thu Oct 29 14:48:28 2009 +0000
+++ b/tools/xenstat/libxenstat/src/xenstat.h	Thu Nov 05 09:28:00 2009 +0800
@@ -183,5 +183,7 @@
 unsigned long long xenstat_vbd_oo_reqs(xenstat_vbd * vbd);
 unsigned long long xenstat_vbd_rd_reqs(xenstat_vbd * vbd);
 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);
 
 #endif /* XENSTAT_H */
diff -r 059c01d69a08 tools/xenstat/libxenstat/src/xenstat_linux.c
--- a/tools/xenstat/libxenstat/src/xenstat_linux.c	Thu Oct 29 14:48:28 2009 +0000
+++ b/tools/xenstat/libxenstat/src/xenstat_linux.c	Thu Nov 05 09:28:00 2009 +0800
@@ -243,6 +243,18 @@
 			continue;
 		}
 
+		if((read_attributes_vbd(dp->d_name, "statistics/rd_sect", buf, 256)<=0)
+		   || ((ret = sscanf(buf, "%llu", &vbd.rd_sects)) != 1))
+		{
+			continue;
+		}
+
+		if((read_attributes_vbd(dp->d_name, "statistics/wr_sect", buf, 256)<=0)
+		   || ((ret = sscanf(buf, "%llu", &vbd.wr_sects)) != 1))
+		{
+			continue;
+		}
+
 		if (domain->vbds == NULL) {
 			domain->num_vbds = 1;
 			domain->vbds = malloc(sizeof(xenstat_vbd));
diff -r 059c01d69a08 tools/xenstat/libxenstat/src/xenstat_priv.h
--- a/tools/xenstat/libxenstat/src/xenstat_priv.h	Thu Oct 29 14:48:28 2009 +0000
+++ b/tools/xenstat/libxenstat/src/xenstat_priv.h	Thu Nov 05 09:28:00 2009 +0800
@@ -92,6 +92,8 @@
 	unsigned long long oo_reqs;
 	unsigned long long rd_reqs;
 	unsigned long long wr_reqs;
+	unsigned long long rd_sects;
+	unsigned long long wr_sects;
 };
 
 extern int xenstat_collect_networks(xenstat_node * node);
diff -r 059c01d69a08 tools/xenstat/xentop/xentop.c
--- a/tools/xenstat/xentop/xentop.c	Thu Oct 29 14:48:28 2009 +0000
+++ b/tools/xenstat/xentop/xentop.c	Thu Nov 05 09:28:00 2009 +0800
@@ -116,6 +116,10 @@
 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);
+static int compare_vbd_rsect(xenstat_domain *domain1, xenstat_domain *domain2);
+static void print_vbd_rsect(xenstat_domain *domain);
+static int compare_vbd_wsect(xenstat_domain *domain1, xenstat_domain *domain2);
+static void print_vbd_wsect(xenstat_domain *domain);
 
 
 /* Section printing functions */
@@ -147,6 +151,8 @@
 	FIELD_VBD_OO,
 	FIELD_VBD_RD,
 	FIELD_VBD_WR,
+	FIELD_VBD_RSECT,
+	FIELD_VBD_WSECT,
 	FIELD_SSID
 } field_id;
 
@@ -159,23 +165,25 @@
 } field;
 
 field fields[] = {
-	{ FIELD_NAME,    "NAME",      10, compare_name,    print_name    },
-	{ FIELD_STATE,   "STATE",      6, compare_state,   print_state   },
-	{ FIELD_CPU,     "CPU(sec)",  10, compare_cpu,     print_cpu     },
-	{ FIELD_CPU_PCT, "CPU(%)",     6, compare_cpu_pct, print_cpu_pct },
-	{ FIELD_MEM,     "MEM(k)",    10, compare_mem,     print_mem     },
-	{ FIELD_MEM_PCT, "MEM(%)",     6, compare_mem,     print_mem_pct },
-	{ FIELD_MAXMEM,  "MAXMEM(k)", 10, compare_maxmem,  print_maxmem  },
-	{ FIELD_MAX_PCT, "MAXMEM(%)",  9, compare_maxmem,  print_max_pct },
-	{ FIELD_VCPUS,   "VCPUS",      5, compare_vcpus,   print_vcpus   },
-	{ 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_VBDS,    "VBDS",       4, compare_vbds,    print_vbds    },
-	{ FIELD_VBD_OO,  "VBD_OO",     8, compare_vbd_oo,  print_vbd_oo  },
-	{ FIELD_VBD_RD,  "VBD_RD",     8, compare_vbd_rd,  print_vbd_rd  },
-	{ FIELD_VBD_WR,  "VBD_WR",     8, compare_vbd_wr,  print_vbd_wr  },
-	{ FIELD_SSID,    "SSID",       4, compare_ssid,    print_ssid    }
+	{ FIELD_NAME,      "NAME",      10, compare_name,      print_name    },
+	{ FIELD_STATE,     "STATE",      6, compare_state,     print_state   },
+	{ FIELD_CPU,       "CPU(sec)",  10, compare_cpu,       print_cpu     },
+	{ FIELD_CPU_PCT,   "CPU(%)",     6, compare_cpu_pct,   print_cpu_pct },
+	{ FIELD_MEM,       "MEM(k)",    10, compare_mem,       print_mem     },
+	{ FIELD_MEM_PCT,   "MEM(%)",     6, compare_mem,       print_mem_pct },
+	{ FIELD_MAXMEM,    "MAXMEM(k)", 10, compare_maxmem,    print_maxmem  },
+	{ FIELD_MAX_PCT,   "MAXMEM(%)",  9, compare_maxmem,    print_max_pct },
+	{ FIELD_VCPUS,     "VCPUS",      5, compare_vcpus,     print_vcpus   },
+	{ 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_VBDS,      "VBDS",       4, compare_vbds,      print_vbds    },
+	{ FIELD_VBD_OO,    "VBD_OO",     8, compare_vbd_oo,    print_vbd_oo  },
+	{ FIELD_VBD_RD,    "VBD_RD",     8, compare_vbd_rd,    print_vbd_rd  },
+	{ FIELD_VBD_WR,    "VBD_WR",     8, compare_vbd_wr,    print_vbd_wr  },
+	{ FIELD_VBD_RSECT, "VBD_RSECT", 10, compare_vbd_rsect, print_vbd_rsect  },
+	{ FIELD_VBD_WSECT, "VBD_WSECT", 10, compare_vbd_wsect, print_vbd_wsect  },
+	{ FIELD_SSID,      "SSID",       4, compare_ssid,      print_ssid    }
 };
 
 const unsigned int NUM_FIELDS = sizeof(fields)/sizeof(field);
@@ -685,20 +693,51 @@
    returning -1,0,1 * for <,=,> */
 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));
+	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));
+	print("%8llu", tot_vbd_reqs(domain, FIELD_VBD_WR));
 }
+
+/* Compares number of total VBD READ sectors of two domains,
+   returning -1,0,1 * for <,=,> */
+static int compare_vbd_rsect(xenstat_domain *domain1, xenstat_domain *domain2)
+{
+	return -compare(tot_vbd_reqs(domain1, FIELD_VBD_RSECT),
+			tot_vbd_reqs(domain2, FIELD_VBD_RSECT));
+}
+
+/* Prints number of total VBD READ sectors statistic */
+static void print_vbd_rsect(xenstat_domain *domain)
+{
+	print("%10llu", tot_vbd_reqs(domain, FIELD_VBD_RSECT));
+}
+
+/* Compares number of total VBD WRITE sectors of two domains,
+   returning -1,0,1 * for <,=,> */
+static int compare_vbd_wsect(xenstat_domain *domain1, xenstat_domain *domain2)
+{
+	return -compare(tot_vbd_reqs(domain1, FIELD_VBD_WSECT),
+			tot_vbd_reqs(domain2, FIELD_VBD_WSECT));
+}
+
+/* Prints number of total VBD WRITE sectors statistic */
+static void print_vbd_wsect(xenstat_domain *domain)
+{
+	print("%10llu", tot_vbd_reqs(domain, FIELD_VBD_WSECT));
+}
+
 
 /* Gets number of total VBD requests statistic, 
  *   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.
+ *   if flag is FIELD_VBD_RD, then READ requests,
+ *   if flag is FIELD_VBD_WR, then WRITE requests,
+ *   if flag is FIELD_VBD_RSECT, then READ sectors,
+ *   if flag is FIELD_VBD_WSECT, then WRITE sectors.
  */
 static unsigned long long tot_vbd_reqs(xenstat_domain *domain, int flag)
 {
@@ -720,6 +759,12 @@
 			break;
 		case FIELD_VBD_WR:
 			total += xenstat_vbd_wr_reqs(vbd);
+			break;
+		case FIELD_VBD_RSECT:
+			total += xenstat_vbd_rd_sects(vbd);
+			break;
+		case FIELD_VBD_WSECT:
+			total += xenstat_vbd_wr_sects(vbd);
 			break;
 		default:
 			break;
@@ -950,12 +995,14 @@
 			 MINOR(xenstat_vbd_dev(vbd)));
 #endif
 
-		print("VBD %s %4d %s OO: %8llu   RD: %8llu   WR: %8llu\n",
+		print("VBD %s %4d %s OO: %8llu   RD: %8llu   WR: %8llu   RSECT: %10llu   WSECT: %10llu\n",
 		      vbd_type[xenstat_vbd_type(vbd)],
 		      xenstat_vbd_dev(vbd), details,
 		      xenstat_vbd_oo_reqs(vbd),
 		      xenstat_vbd_rd_reqs(vbd),
-		      xenstat_vbd_wr_reqs(vbd));
+		      xenstat_vbd_wr_reqs(vbd),
+		      xenstat_vbd_rd_sects(vbd),
+		      xenstat_vbd_wr_sects(vbd));
 	}
 }
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2009-11-05 10:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AF2A659.6060300@intel.com \
    --to=xiaowei.yang@intel.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.