Skip to contentSkip to conversation

Expose RUNstate_blocked,offline,runnable in xentop?

PATCH Konrad Rzeszutek Wilk 2 participants 2 messages May 17, 2016

lore
Share & tools
lore
#0 lore raw

Hey,

I was wondering if there is an interest in exposing those via xentop?

I wrote a hack patch (see attached) that expose this which helped me figure out what guests are doing when their CPU consumption time is low. As in whether they are truly 'halted' or if they are preempted by the hypervisor or other guests (b/c I may have pinned _ALL_ guest VCPUs on the same pCPU).

Of course I am not proposing the patches as they are.

Quoted 1 line

From ee7abce84ea4e4fbaad9c03793d9b75e07e15ca3 Mon Sep 17 00:00:00 2001

From: Konrad Rzeszutek Wilk <[email protected]>
Date: Fri, 4 Apr 2014 15:24:22 -0400
Subject: [PATCH 1/2] xen/xentop: Include RUNNABLE, OFFLINE, and BLOCKED stats

---
 tools/libxc/xc_domain.c                     |  26 ++++++
 tools/libxc/xenctrl.h                       |   6 ++
 tools/xenstat/libxenstat/src/xenstat.c      |  24 +++++-
 tools/xenstat/libxenstat/src/xenstat.h      |   3 +
 tools/xenstat/libxenstat/src/xenstat_priv.h |   3 +
 tools/xenstat/xentop/xentop.c               | 129 ++++++++++++++++++++++------
 xen/common/domctl.c                         |  63 ++++++++++++++
 xen/common/sysctl.c                         |  43 ++++++++++
 xen/include/public/domctl.h                 |  47 ++++++++++
 xen/include/public/sysctl.h                 |  13 +++
 xen/include/xen/domain.h                    |   2 +
 11 files changed, 332 insertions(+), 27 deletions(-)
tools/libxc/xc_domain.c +26 -0
index 369c3f3..028eb4f 100644
@@ -281,6 +281,32 @@ int xc_vcpu_getaffinity(xc_interface *xch,
 out:
     return ret;
 }
+int xc_domain_getinfolist2(xc_interface *xch,
+                          uint32_t first_domain,
+                          unsigned int max_domains,
+                          xc_domaininfo2_t *info)
+{
+    int ret = 0;
+    DECLARE_SYSCTL;
+    DECLARE_HYPERCALL_BOUNCE(info, max_domains*sizeof(*info), XC_HYPERCALL_BUFFER_BOUNCE_OUT);
+
+    if ( xc_hypercall_bounce_pre(xch, info) )
+        return -1;
+
+    sysctl.cmd = XEN_SYSCTL_getdomaininfolist2;
+    sysctl.u.getdomaininfolist.first_domain = first_domain;
+    sysctl.u.getdomaininfolist.max_domains  = max_domains;
+    set_xen_guest_handle(sysctl.u.getdomaininfolist.buffer, info);
+
+    if ( xc_sysctl(xch, &sysctl) < 0 )
+        ret = -1;
+    else
+        ret = sysctl.u.getdomaininfolist.num_domains;
+
+    xc_hypercall_bounce_post(xch, info);
+
+    return ret;
+}
 
 int xc_domain_get_guest_width(xc_interface *xch, uint32_t domid,
                               unsigned int *guest_width)
tools/libxc/xenctrl.h +6 -0
index 42d3133..2100e8f 100644
@@ -420,6 +420,7 @@ typedef struct xc_dominfo {
 } xc_dominfo_t;
 
 typedef xen_domctl_getdomaininfo_t xc_domaininfo_t;
+typedef xen_domctl_getdomaininfo2_t xc_domaininfo2_t;
 
 typedef union 
 {
@@ -625,6 +626,11 @@ int xc_domain_getinfo(xc_interface *xch,
                       xc_dominfo_t *info);
 
 
+int xc_domain_getinfolist2(xc_interface *xch,
+                          uint32_t first_domain,
+                          unsigned int max_domains,
+                          xc_domaininfo2_t *info);
+
 /**
  * This function will set the execution context for the specified vcpu.
  *
tools/xenstat/libxenstat/src/xenstat.c +22 -2
index e5facb8..936cb02 100644
@@ -163,7 +163,7 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags)
 #define DOMAIN_CHUNK_SIZE 256
 	xenstat_node *node;
 	xc_physinfo_t physinfo = { 0 };
-	xc_domaininfo_t domaininfo[DOMAIN_CHUNK_SIZE];
+	xc_domaininfo2_t domaininfo[DOMAIN_CHUNK_SIZE];
 	unsigned int new_domains;
 	unsigned int i;
 
@@ -204,7 +204,7 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags)
 	do {
 		xenstat_domain *domain, *tmp;
 
-		new_domains = xc_domain_getinfolist(handle->xc_handle,
+		new_domains = xc_domain_getinfolist2(handle->xc_handle,
 						    node->num_domains, 
 						    DOMAIN_CHUNK_SIZE, 
 						    domaininfo);
@@ -244,6 +244,9 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags)
 			}
 			domain->state = domaininfo[i].flags;
 			domain->cpu_ns = domaininfo[i].cpu_time;
+			domain->cpu_blocked_ns = domaininfo[i].cpu_time_blocked;
+			domain->cpu_offline_ns = domaininfo[i].cpu_time_offline;
+			domain->cpu_runnable_ns = domaininfo[i].cpu_time_runnable;
 			domain->num_vcpus = (domaininfo[i].max_vcpu_id+1);
 			domain->vcpus = NULL;
 			domain->cur_mem =
@@ -379,6 +382,18 @@ unsigned long long xenstat_domain_cpu_ns(xenstat_domain * domain)
 {
 	return domain->cpu_ns;
 }
+unsigned long long xenstat_domain_cpu_offline_ns(xenstat_domain * domain)
+{
+	return domain->cpu_offline_ns;
+}
+unsigned long long xenstat_domain_cpu_runnable_ns(xenstat_domain * domain)
+{
+	return domain->cpu_runnable_ns;
+}
+unsigned long long xenstat_domain_cpu_blocked_ns(xenstat_domain * domain)
+{
+	return domain->cpu_blocked_ns;
+}
 
 /* Find the number of VCPUs for a domain */
 unsigned int xenstat_domain_num_vcpus(xenstat_domain * domain)
@@ -546,6 +561,11 @@ unsigned long long xenstat_vcpu_ns(xenstat_vcpu * vcpu)
 {
 	return vcpu->ns;
 }
+/* Get VCPU usage */
+unsigned long long xenstat_vcpu_offline_ns(xenstat_vcpu * vcpu)
+{
+	return vcpu->ns;
+}
 
 /*
  * Network functions
tools/xenstat/libxenstat/src/xenstat.h +3 -0
index 47ec60e..a7c70ab 100644
@@ -94,6 +94,9 @@ char *xenstat_domain_name(xenstat_domain * domain);
 
 /* Get information about how much CPU time has been used */
 unsigned long long xenstat_domain_cpu_ns(xenstat_domain * domain);
+unsigned long long xenstat_domain_cpu_blocked_ns(xenstat_domain * domain);
+unsigned long long xenstat_domain_cpu_runnable_ns(xenstat_domain * domain);
+unsigned long long xenstat_domain_cpu_offline_ns(xenstat_domain * domain);
 
 /* Find the number of VCPUs allocated to a domain */
 unsigned int xenstat_domain_num_vcpus(xenstat_domain * domain);
tools/xenstat/libxenstat/src/xenstat_priv.h +3 -0
index 8490e23..5c257bb 100644
@@ -64,6 +64,9 @@ struct xenstat_domain {
 	char *name;
 	unsigned int state;
 	unsigned long long cpu_ns;
+	unsigned long long cpu_blocked_ns;
+	unsigned long long cpu_offline_ns;
+	unsigned long long cpu_runnable_ns;
 	unsigned int num_vcpus;		/* No. vcpus configured for domain */
 	xenstat_vcpu *vcpus;		/* Array of length num_vcpus */
 	unsigned long long cur_mem;	/* Current memory reservation */
tools/xenstat/xentop/xentop.c +104 -25

215 lines not on this page · raw message

xen/common/domctl.c +63 -0

69 lines not on this page · raw message

xen/common/sysctl.c +43 -0

49 lines not on this page · raw message

xen/include/public/domctl.h +47 -0

59 lines not on this page · raw message

xen/include/public/sysctl.h +13 -0
index eecb839..ff9be43 100644
@@ -161,6 +161,17 @@ struct xen_sysctl_getdomaininfolist {
 typedef struct xen_sysctl_getdomaininfolist xen_sysctl_getdomaininfolist_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist_t);
 
+struct xen_sysctl_getdomaininfolist2 {
+    /* IN variables. */
+    domid_t               first_domain;
+    uint32_t              max_domains;
+    XEN_GUEST_HANDLE_64(xen_domctl_getdomaininfo2_t) buffer;
+    /* OUT variables. */
+    uint32_t              num_domains;
+};
+typedef struct xen_sysctl_getdomaininfolist2 xen_sysctl_getdomaininfolist2_t;
+DEFINE_XEN_GUEST_HANDLE(xen_sysctl_getdomaininfolist2_t);
+
 /* Inject debug keys into Xen. */
 /* XEN_SYSCTL_debug_keys */
 struct xen_sysctl_debug_keys {
@@ -824,6 +835,7 @@ struct xen_sysctl {
  * it.
  */
 #define XEN_SYSCTL_xsplice_op                    27
+#define XEN_SYSCTL_getdomaininfolist2            28
     uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
     union {
         struct xen_sysctl_readconsole       readconsole;
@@ -846,6 +858,7 @@ struct xen_sysctl {
         struct xen_sysctl_scheduler_op      scheduler_op;
         struct xen_sysctl_coverage_op       coverage_op;
         struct xen_sysctl_xsplice_op        xsplice;
+        struct xen_sysctl_getdomaininfolist2 getdomaininfolist2;
         uint8_t                             pad[128];
     } u;
 };
xen/include/xen/domain.h +2 -0
index a057069..2868363 100644
@@ -16,7 +16,9 @@ struct vcpu *alloc_dom0_vcpu0(void);
 int vcpu_reset(struct vcpu *);
 
 struct xen_domctl_getdomaininfo;
+struct xen_domctl_getdomaininfo2;
 void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info);
+void getdomaininfo2(struct domain *d, struct xen_domctl_getdomaininfo2 *info);
 
 /*
  * Arch-specifics.
Signature · 1 line
2.4.3
Quoted 1 line

From e48a447d505036089c1544cde2ab9648eabf595c Mon Sep 17 00:00:00 2001

From: Konrad Rzeszutek Wilk <[email protected]>
Date: Tue, 8 Apr 2014 11:07:36 -0400
Subject: [PATCH 2/2] xentop: When running with -R don't output everything.

---
 tools/xenstat/xentop/xentop.c | 49 ++++++++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 22 deletions(-)
tools/xenstat/xentop/xentop.c +27 -22

70 lines not on this page · raw message

Signature · 1 line
2.4.3

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw

Re: Expose RUNstate_blocked, offline, runnable in xentop?

Quoted 11 lines · Konrad Rzeszutek Wilk

Hey,

I was wondering if there is an interest in exposing those via xentop?

I wrote a hack patch (see attached) that expose this which helped me figure out what guests are doing when their CPU consumption time is low. As in whether they are truly 'halted' or if they are preempted by the hypervisor or other guests (b/c I may have pinned _ALL_ guest VCPUs on the same pCPU).

Yes, IMO, this is something that could well be interesting!

Quoted 2 lines

Of course I am not proposing the patches as they are.

Cc me when you do.

I'm a little busy for a couple of days, but I'll do my best to help this to get in (for 4.8, of course).

Regards,
Dario

Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel