Skip to contentSkip to conversation

timers: Set the deadline more accurately

PATCH New Ross Lagerwall 1 participant 1 message May 21, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 timers: Set the deadline more accurately

Program the timer to the deadline of the closest timer if it is further than 50us ahead, otherwise set it 50us ahead. This way a single event fires on time rather than 50us late (as it would have previously) while still preventing too many timer wakeups in the case of having many timers scheduled close together.

(where 50us is the timer_slop)

---
 xen/common/timer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/common/timer.c +2 -1
index 1895a78..f36aebc 100644
@@ -492,8 +492,9 @@ static void timer_softirq_action(void)
         deadline = heap[1]->expires;
     if ( (ts->list != NULL) && (ts->list->expires < deadline) )
         deadline = ts->list->expires;
+    now = NOW();
     this_cpu(timer_deadline) =
-        (deadline == STIME_MAX) ? 0 : deadline + timer_slop;
+        (deadline == STIME_MAX) ? 0 : MAX(deadline, now + timer_slop);
 
     if ( !reprogram_timer(this_cpu(timer_deadline)) )
         raise_softirq(TIMER_SOFTIRQ);
Signature · 1 line
1.9.0