diff options
author | Steven Hand <steven@xensource.com> | 2007-06-27 21:01:08 +0100 |
---|---|---|
committer | Steven Hand <steven@xensource.com> | 2007-06-27 21:01:08 +0100 |
commit | 3bc33badf2f2afcb61dca3ee5446e4c13f0c26b4 (patch) | |
tree | 1cdbf0b71c06cedc476fffaa68abd2c2db35b83a /xen/common/sysctl.c | |
parent | cee3908623186dd5e0bd79f302f65671deea799c (diff) | |
download | xen-3bc33badf2f2afcb61dca3ee5446e4c13f0c26b4.tar.gz xen-3bc33badf2f2afcb61dca3ee5446e4c13f0c26b4.tar.bz2 xen-3bc33badf2f2afcb61dca3ee5446e4c13f0c26b4.zip |
Add new sysctl to return runtime information about physical CPU utilization.
Signed-off-by: Steven Hadn <steven@xensource.com>
Diffstat (limited to 'xen/common/sysctl.c')
-rw-r--r-- | xen/common/sysctl.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index 0cba2c1164..28cbf9b71f 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -136,6 +136,38 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl) } break; + case XEN_SYSCTL_cpuinfo: + { + uint32_t i, nr_cpus; + uint64_t idletime; + + nr_cpus = (op->u.cpuinfo.max_cpus > NR_CPUS) ? NR_CPUS : + op->u.cpuinfo.max_cpus; + + for ( i = 0; i < nr_cpus; i++ ) + { + if(!idle_vcpu[i]) + /* XXX: assumes no further CPUs after first missing one */ + break; + + /* somewhat imprecise but should suffice */ + idletime = idle_vcpu[i]->runstate.time[RUNSTATE_running] + + (NOW() - idle_vcpu[i]->runstate.state_entry_time); + if ( copy_to_guest_offset(op->u.cpuinfo.buffer, i, &idletime, 1) ) + { + ret = -EFAULT; + break; + } + } + + op->u.cpuinfo.nr_cpus = i; + ret = 0; + + if( copy_to_guest (u_sysctl, op, 1) ) + ret = -EFAULT; + } + break; + default: ret = arch_do_sysctl(op, u_sysctl); break; |