]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/qemu-xen-traditional.git/commitdiff
timers: use INT64_MAX as max expiration
authorYang Zhang <yang.z.zhang@Intel.com>
Tue, 3 Apr 2012 14:44:48 +0000 (15:44 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 3 Apr 2012 14:44:48 +0000 (15:44 +0100)
Currently, the max expiration time is 2147483647ns(INT32_MAX ns). This
is enough when guest is busy, but when guest is idle, the next timer
will be later than INT32_MAX ns. And those meaningless alarm will harm
the pkg C-state.

PS: Since the overflow will not happen with the expression((delta /
1000) + (delta % 1000 > 0 ? 1 : 0)), so i also removed the comments"
To avoid problems with overflow limit this to 2^32."

Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
vl.c

diff --git a/vl.c b/vl.c
index be8587a9e8f4fc38ef2db60a8f000f1c899fb374..d30cb2c02af6a0ba2eb970003ded880f130ea595 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -1410,8 +1410,7 @@ static int64_t qemu_next_deadline(void)
         delta = active_timers[QEMU_TIMER_VIRTUAL]->expire_time -
                      qemu_get_clock(vm_clock);
     } else {
-        /* To avoid problems with overflow limit this to 2^32.  */
-        delta = INT32_MAX;
+        delta = INT64_MAX;
     }
 
     if (delta < 0)
@@ -1427,9 +1426,11 @@ static uint64_t qemu_next_deadline_dyntick(void)
     int64_t rtdelta;
 
     if (use_icount)
-        delta = INT32_MAX;
-    else
-        delta = (qemu_next_deadline() + 999) / 1000;
+        delta = INT64_MAX;
+    else {
+        delta = qemu_next_deadline();
+        delta = (delta / 1000) + (delta % 1000 > 0 ? 1 : 0);
+    }
 
     if (active_timers[QEMU_TIMER_REALTIME]) {
         rtdelta = (active_timers[QEMU_TIMER_REALTIME]->expire_time -
@@ -3872,8 +3873,8 @@ int main_loop(void)
                     env->icount_decr.u16.low = 0;
                     env->icount_extra = 0;
                     count = qemu_next_deadline();
-                    count = (count + (1 << icount_time_shift) - 1)
-                            >> icount_time_shift;
+                    count = (count >> icount_time_shift) +
+                        ((count & ((1 << icount_time_shift) - 1)) > 0 ? 1 : 0);
                     qemu_icount += count;
                     decr = (count > 0xffff) ? 0xffff : count;
                     count -= decr;