Fix for VCPU periodic timer.
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 3 Sep 2008 10:02:57 +0000 (11:02 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 3 Sep 2008 10:02:57 +0000 (11:02 +0100)
Idle vcpu periodic timer is useless. It increased the lapic timer
interrupt number, which decreased the cpu idle residency. This patch
disables idle vcpu periodic timer via keeping v->periodic_period = 0.

The vcpu periodic timer may be expired 50us before expected time
because there is a 50us TIMER_SLOP used for soft timer (xen/common/timer.c,
timer_softirq_action()). This will cause vcpu_periodic_timer_work() be
continuously called tens of times in a single call of
timer_softirq_action() until (now > periodic_next_event). It brings
unnecessary overhead. This patch adds a similar time slop in vcpu
periodic timer to eliminate this overhead.

Signed-off-by: Wei Gang <gang.wei@intel.com>
xen/arch/x86/domain.c
xen/common/schedule.c

index 1dc24924e6f8db028de819a521bf4a5bdbcd71dc..10d0cef7c652bef24899a6984a6c60790e273e56 100644 (file)
@@ -302,7 +302,8 @@ int vcpu_initialise(struct vcpu *v)
     else
     {
         /* PV guests by default have a 100Hz ticker. */
-        v->periodic_period = MILLISECS(10);
+        if ( !is_idle_domain(d) )
+            v->periodic_period = MILLISECS(10);
 
         /* PV guests get an emulated PIT too for video BIOSes to use. */
         if ( !is_idle_domain(d) && (v->vcpu_id == 0) )
index 2934d07029d43b373709c8a0584a6b429d5ad765..7d32c99485572e09c2e58a2054f29df0eab04a23 100644 (file)
@@ -628,7 +628,9 @@ static void vcpu_periodic_timer_work(struct vcpu *v)
         return;
 
     periodic_next_event = v->periodic_last_event + v->periodic_period;
-    if ( now > periodic_next_event )
+
+    /* The timer subsystem may call us up to TIME_SLOP ahead of deadline. */
+    if ( (now + TIME_SLOP) > periodic_next_event )
     {
         send_timer_event(v);
         v->periodic_last_event = now;