Re: [Xen-devel] Expose RUNstate_blocked, offline, runnable in xentop?

2016-05-17 Thread Dario Faggioli
On Tue, 2016-05-17 at 11:07 -0400, Konrad Rzeszutek Wilk wrote:
> 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!

> 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
-- 
<> (Raistlin Majere)
-
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R Ltd., Cambridge (UK)



signature.asc
Description: This is a digitally signed message part
___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] Expose RUNstate_blocked,offline,runnable in xentop?

2016-05-17 Thread 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).

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

>From ee7abce84ea4e4fbaad9c03793d9b75e07e15ca3 Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk 
Date: Fri, 4 Apr 2014 15:24:22 -0400
Subject: [PATCH 1/2] xen/xentop: Include RUNNABLE, OFFLINE, and BLOCKED stats

Signed-off-by: Konrad Rzeszutek Wilk 
---
 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(-)

diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 369c3f3..028eb4f 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -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, ) < 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)
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index 42d3133..2100e8f 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -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.
  *
diff --git a/tools/xenstat/libxenstat/src/xenstat.c 
b/tools/xenstat/libxenstat/src/xenstat.c
index e5facb8..936cb02 100644
--- a/tools/xenstat/libxenstat/src/xenstat.c
+++ b/tools/xenstat/libxenstat/src/xenstat.c
@@ -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;