vm-stat utility
PATCH 1/1 vm-stat utility
Below is a utility which outputs utilization CPU by domain and by phys CPU. We used this for some OLS work last year, and we have received some requests for the patch. We needed this utility because we wanted to know which and how much of a phys CPU a domain was consuming, and we wanted output to be easily redirected to a text file, to be processed later.
This patch is quite old (and very rough on the edges), but it should still apply to current xen-unstable. It was originally based off xentop code (I am certain there are many lines in there, originally for xentop, which are not even needed for vm-stat). I should also state that its ability to attribute a domain's vCPU time to a pCPU is not very accurate anymore with the addition of credit scheduler and load balancing. When we did not load balance, it was pretty easy to assume a vCPU's time was all spent on one pCPU -not the case anymore. If you want accurate vCPU->pCPU usage, I think we would need some additional data in vcpu struct, or just pin vCPUs to pCPUS for your tests.
I am not sure if this utility is of any use to anyone these days, but I wanted to make it available just in case. I am not asking to have this included in xen, but if someone else finds it useful and wants to clean it up, have fun!
-Andrew
<signed-off-by: Andrew Theurer [email protected]>
tools/xenstat/libxenstat/src/xenstat.c +0 -0
@@ -63,6 +63,7 @@ struct xenstat_domain {
struct xenstat_vcpu {
unsigned int online;
unsigned long long ns;+ int phys_cpu;
};
struct xenstat_network {
@@ -451,6 +452,7 @@ static int xenstat_collect_vcpus(xenstat
node->domains[i].vcpus[vcpu].online = info.online; node->domains[i].vcpus[vcpu].ns = info.cpu_time; + node->domains[i].vcpus[vcpu].phys_cpu = info.cpu; } } return 1; @@ -475,6 +477,12 @@ unsigned int xenstat_vcpu_online(xenstat return vcpu->online; }
+/* Get VCPU to PHYSCPU mapping */
+int xenstat_vcpu_physcpu(xenstat_vcpu * vcpu) +{
+ return vcpu->phys_cpu;
+}
+
/* Get VCPU usage */
unsigned long long xenstat_vcpu_ns(xenstat_vcpu * vcpu) {
tools/xenstat/libxenstat/src/xenstat.h +3 -0
@@ -118,6 +118,9 @@ xenstat_network *xenstat_domain_network(* VCPU functions - extract information from a xenstat_vcpu */ +/* Get VCPU to PHYSCPU mapping */ +int xenstat_vcpu_physcpu (xenstat_vcpu * vcpu); +
/* Get VCPU usage */
unsigned int xenstat_vcpu_online(xenstat_vcpu * vcpu); unsigned long long xenstat_vcpu_ns(xenstat_vcpu * vcpu);
tools/xenstat/Makefile +0 -0
@@ -6,7 +6,7 @@ SUBDIRS += libxenstat
# This doesn't cross-compile (cross-compile environments rarely have curses) ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
-SUBDIRS += xentop
+SUBDIRS += xentop vm-stat
endif
.PHONY: all install clean
tools/xenstat/vm-stat/Makefile +42 -0
42 lines not on this page · raw message
tools/xenstat/vm-stat/vm-stat.c +164 -0
164 lines not on this page · raw message