[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Improve guest time keeping



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID d6af2ea42f94f691e9b55e0383af06910b6bdc8a
# Parent  eba58fc9f755c77ab3f7028dd9dc7ec6a5566132

Improve guest time keeping

Even though we accounted for lost ticks, the accounting was not precise.
Specifically, we didn't account for the delay in calling the ac_timer
handler.

Signed-off-by: Eddie Dong <eddie.dong@xxxxxxxxx>
Signed-off-by: Arun Sharma <arun.sharma@xxxxxxxxx>

diff -r eba58fc9f755 -r d6af2ea42f94 xen/arch/x86/vmx_intercept.c
--- a/xen/arch/x86/vmx_intercept.c      Mon Jul 25 21:03:25 2005
+++ b/xen/arch/x86/vmx_intercept.c      Mon Jul 25 21:03:40 2005
@@ -197,12 +197,23 @@
 static void pit_timer_fn(void *data)
 {
     struct vmx_virpit_t *vpit = data;
+    s_time_t   next;
+    int        missed_ticks;
+
+    missed_ticks = (NOW() - vpit->scheduled) / MILLISECS(vpit->period);
 
     /* Set the pending intr bit, and send evtchn notification to myself. */
     if (test_and_set_bit(vpit->vector, vpit->intr_bitmap))
         vpit->pending_intr_nr++; /* already set, then count the pending intr */
 
-    set_ac_timer(&vpit->pit_timer, NOW() + MILLISECS(vpit->period));
+    /* pick up missed timer tick */
+    if ( missed_ticks > 0 ) {
+        vpit->pending_intr_nr+= missed_ticks;
+        vpit->scheduled += missed_ticks * MILLISECS(vpit->period);
+    }
+    next = vpit->scheduled + MILLISECS(vpit->period);
+    set_ac_timer(&vpit->pit_timer, next);
+    vpit->scheduled = next;
 }
 
 
@@ -263,7 +274,8 @@
 
         vpit->intr_bitmap = intr;
 
-       set_ac_timer(&vpit->pit_timer, NOW() + MILLISECS(vpit->period));
+        vpit->scheduled = NOW() + MILLISECS(vpit->period);
+        set_ac_timer(&vpit->pit_timer, vpit->scheduled);
 
         /*restore the state*/
         p->state = STATE_IORESP_READY;
diff -r eba58fc9f755 -r d6af2ea42f94 xen/include/asm-x86/vmx_virpit.h
--- a/xen/include/asm-x86/vmx_virpit.h  Mon Jul 25 21:03:25 2005
+++ b/xen/include/asm-x86/vmx_virpit.h  Mon Jul 25 21:03:40 2005
@@ -19,6 +19,7 @@
     /* for simulation of counter 0 in mode 2*/
     int vector;                                /* the pit irq vector */
     unsigned int period;               /* the frequency. e.g. 10ms*/
+    s_time_t scheduled;                 /* scheduled timer interrupt */
     unsigned int channel;              /* the pit channel, counter 0~2 */
     u64  *intr_bitmap;
     unsigned int pending_intr_nr;      /* the couner for pending timer 
interrupts */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.