aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/sysctl.c
diff options
context:
space:
mode:
authorKeir Fraser <keir@xensource.com>2007-06-27 21:27:51 +0100
committerKeir Fraser <keir@xensource.com>2007-06-27 21:27:51 +0100
commit4706b975b068905baf16fbd42d12da825143b25d (patch)
treeb1afc49aa62b9536c5d387d92c1ea2e45b65ae05 /xen/common/sysctl.c
parent3f96f21796c6ab5ffec50b70e0457d973eb5d9c2 (diff)
downloadxen-4706b975b068905baf16fbd42d12da825143b25d.tar.gz
xen-4706b975b068905baf16fbd42d12da825143b25d.tar.bz2
xen-4706b975b068905baf16fbd42d12da825143b25d.zip
Small sysctl cleanups.
Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'xen/common/sysctl.c')
-rw-r--r--xen/common/sysctl.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 28cbf9b71f..16a6b5fb31 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -140,19 +140,20 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
{
uint32_t i, nr_cpus;
uint64_t idletime;
+ struct vcpu *v;
- nr_cpus = (op->u.cpuinfo.max_cpus > NR_CPUS) ? NR_CPUS :
- op->u.cpuinfo.max_cpus;
+ nr_cpus = min_t(uint32_t, op->u.cpuinfo.max_cpus, NR_CPUS);
for ( i = 0; i < nr_cpus; i++ )
{
- if(!idle_vcpu[i])
- /* XXX: assumes no further CPUs after first missing one */
+ /* Assume no holes in idle-vcpu map. */
+ if ( (v = idle_vcpu[i]) == NULL )
break;
- /* somewhat imprecise but should suffice */
- idletime = idle_vcpu[i]->runstate.time[RUNSTATE_running] +
- (NOW() - idle_vcpu[i]->runstate.state_entry_time);
+ idletime = v->runstate.time[RUNSTATE_running];
+ if ( v->is_running )
+ idletime += NOW() - v->runstate.state_entry_time;
+
if ( copy_to_guest_offset(op->u.cpuinfo.buffer, i, &idletime, 1) )
{
ret = -EFAULT;
@@ -163,7 +164,7 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
op->u.cpuinfo.nr_cpus = i;
ret = 0;
- if( copy_to_guest (u_sysctl, op, 1) )
+ if ( copy_to_guest(u_sysctl, op, 1) )
ret = -EFAULT;
}
break;