[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [RFC 3/6] sysctl: extend XEN_SYSCTL_getcpuinfo interface



From: Andrii Anisov <andrii_anisov@xxxxxxxx>

Extend XEN_SYSCTL_getcpuinfo interface with guest and hypervisor
time information.

Signed-off-by: Andrii Anisov <andrii_anisov@xxxxxxxx>
---
 xen/common/schedule.c       | 22 ++++++++++++++++++++++
 xen/common/sysctl.c         |  2 ++
 xen/include/public/sysctl.h |  2 ++
 xen/include/xen/sched.h     |  2 ++
 4 files changed, 28 insertions(+)

diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 0a38d4a..9e8805d 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -217,6 +217,28 @@ uint64_t get_cpu_idle_time(unsigned int cpu)
     return state.time[RUNSTATE_blocked];
 }
 
+uint64_t get_cpu_guest_time(unsigned int cpu)
+{
+    struct vcpu_runstate_info state = { 0 };
+    struct vcpu *v = idle_vcpu[cpu];
+
+    if ( cpu_online(cpu) && v )
+        vcpu_runstate_get(v, &state);
+
+    return state.time[RUNSTATE_runnable];
+}
+
+uint64_t get_cpu_hyp_time(unsigned int cpu)
+{
+    struct vcpu_runstate_info state = { 0 };
+    struct vcpu *v = idle_vcpu[cpu];
+
+    if ( cpu_online(cpu) && v )
+        vcpu_runstate_get(v, &state);
+
+    return state.time[RUNSTATE_running];
+}
+
 /*
  * If locks are different, take the one with the lower address first.
  * This avoids dead- or live-locks when this code is running on both
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 765effd..c4abb11 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -152,6 +152,8 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
         for ( i = 0; i < nr_cpus; i++ )
         {
             cpuinfo.idletime = get_cpu_idle_time(i);
+            cpuinfo.guesttime = get_cpu_guest_time(i);
+            cpuinfo.hyptime = get_cpu_hyp_time(i);
 
             if ( copy_to_guest_offset(op->u.getcpuinfo.info, i, &cpuinfo, 1) )
                 goto out;
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index 91c48dc..1a4e4de 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -164,6 +164,8 @@ struct xen_sysctl_debug_keys {
 /* XEN_SYSCTL_getcpuinfo */
 struct xen_sysctl_cpuinfo {
     uint64_aligned_t idletime;
+    uint64_aligned_t hyptime;
+    uint64_aligned_t guesttime;
 };
 typedef struct xen_sysctl_cpuinfo xen_sysctl_cpuinfo_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpuinfo_t);
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index b40c8fd..5e28797 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -882,6 +882,8 @@ int vcpu_pin_override(struct vcpu *v, int cpu);
 
 void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate);
 uint64_t get_cpu_idle_time(unsigned int cpu);
+uint64_t get_cpu_hyp_time(unsigned int cpu);
+uint64_t get_cpu_guest_time(unsigned int cpu);
 
 /*
  * Used by idle loop to decide whether there is work to do:
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.