Initialize state_entry_time to zero for all idle vcpus
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 10 Dec 2008 13:41:34 +0000 (13:41 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 10 Dec 2008 13:41:34 +0000 (13:41 +0000)
NOW() is not usable since xen time sub-system hasn't
been initialized yet. On my box, it gives a initial
stamp ~60s due to local tsc stamp as zero and TSC
count is started from power on. Then a negative value
is added to runstate of that idle vcpu at schedule
point. The net effect is for some tool like xenpm
to show a big idle time gap between BSP and other APs.

Signed-off-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/common/domain.c

index 8c97a2b3a8f0393225e89c86b7334c3244ffc815..a48033cfc70c188ce3f1e47e7c339849efcc787f 100644 (file)
@@ -144,13 +144,16 @@ struct vcpu *alloc_vcpu(
     v->domain = d;
     v->vcpu_id = vcpu_id;
 
-    v->runstate.state = is_idle_vcpu(v) ? RUNSTATE_running : RUNSTATE_offline;
-    v->runstate.state_entry_time = NOW();
-
     spin_lock_init(&v->virq_lock);
 
-    if ( !is_idle_domain(d) )
+    if ( is_idle_domain(d) )
+    {
+        v->runstate.state = RUNSTATE_running;
+    }
+    else
     {
+        v->runstate.state = RUNSTATE_offline;        
+        v->runstate.state_entry_time = NOW();
         set_bit(_VPF_down, &v->pause_flags);
         v->vcpu_info = (void *)&shared_info(d, vcpu_info[vcpu_id]);
     }