Skip to contentSkip to conversation

Fix domain CPU time calculation to count all VCPU times correctly

PATCH In review Josh Triplett 2 participants 2 messages Aug 8, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix domain CPU time calculation to count all VCPU times correctly

Currently, the getdomaininfo function (used to fill in a dom0_getdomaininfo_t for a domain) calculates a domain's total CPU time from its VCPU times using the code:

        if ( v->cpu_time > cpu_time )
            cpu_time += v->cpu_time;

This causes a VCPU's time to only be counted if it is greater than the current total; so if VCPU0 has 10 seconds and VCPU1 has 5, the total will be 10, but if VCPU0 has 5 and VCPU10 has 10, the total will be 15. Is there a reason for this behavior? It seems more useful and intuitive to always total the VCPU times to obtain the CPU time.

The attached patch removes the conditional, so that all VCPU times for a domain are always totaled to obtain the CPU time for that domain.

- Josh Triplett

xen/common/dom0_ops.c +1 -2
diff -r 69b7c9c3a9fd xen/common/dom0_ops.c
@@ -70,8 +70,7 @@
             flags &= ~DOMFLAGS_BLOCKED;
         if ( v->vcpu_flags & VCPUF_running )
             flags |= DOMFLAGS_RUNNING;
-        if ( v->cpu_time > cpu_time )
-            cpu_time += v->cpu_time;
+        cpu_time += v->cpu_time;
         vcpu_count++;
     }
     

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 5 lines · Josh Triplett

This causes a VCPU's time to only be counted if it is greater than the current total; so if VCPU0 has 10 seconds and VCPU1 has 5, the total will be 10, but if VCPU0 has 5 and VCPU10 has 10, the total will be 15. Is there a reason for this behavior? It seems more useful and intuitive to always total the VCPU times to obtain the CPU time.

I think we used to return the highest VCPU time as domain time. Someone decided to instead sum across all VCPU times, but I guess forgot to remove the conditional. :-)

-- Keir