ia64/xen-unstable

changeset 5858:d6af2ea42f94

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@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Jul 25 21:03:40 2005 +0000 (2005-07-25)
parents eba58fc9f755
children ecb17ef5a587
files xen/arch/x86/vmx_intercept.c xen/include/asm-x86/vmx_virpit.h
line diff
     1.1 --- a/xen/arch/x86/vmx_intercept.c	Mon Jul 25 21:03:25 2005 +0000
     1.2 +++ b/xen/arch/x86/vmx_intercept.c	Mon Jul 25 21:03:40 2005 +0000
     1.3 @@ -197,12 +197,23 @@ int intercept_pit_io(ioreq_t *p)
     1.4  static void pit_timer_fn(void *data)
     1.5  {
     1.6      struct vmx_virpit_t *vpit = data;
     1.7 +    s_time_t   next;
     1.8 +    int        missed_ticks;
     1.9 +
    1.10 +    missed_ticks = (NOW() - vpit->scheduled) / MILLISECS(vpit->period);
    1.11  
    1.12      /* Set the pending intr bit, and send evtchn notification to myself. */
    1.13      if (test_and_set_bit(vpit->vector, vpit->intr_bitmap))
    1.14          vpit->pending_intr_nr++; /* already set, then count the pending intr */
    1.15  
    1.16 -    set_ac_timer(&vpit->pit_timer, NOW() + MILLISECS(vpit->period));
    1.17 +    /* pick up missed timer tick */
    1.18 +    if ( missed_ticks > 0 ) {
    1.19 +        vpit->pending_intr_nr+= missed_ticks;
    1.20 +        vpit->scheduled += missed_ticks * MILLISECS(vpit->period);
    1.21 +    }
    1.22 +    next = vpit->scheduled + MILLISECS(vpit->period);
    1.23 +    set_ac_timer(&vpit->pit_timer, next);
    1.24 +    vpit->scheduled = next;
    1.25  }
    1.26  
    1.27  
    1.28 @@ -263,7 +274,8 @@ void vmx_hooks_assist(struct vcpu *d)
    1.29  
    1.30          vpit->intr_bitmap = intr;
    1.31  
    1.32 -	set_ac_timer(&vpit->pit_timer, NOW() + MILLISECS(vpit->period));
    1.33 +        vpit->scheduled = NOW() + MILLISECS(vpit->period);
    1.34 +        set_ac_timer(&vpit->pit_timer, vpit->scheduled);
    1.35  
    1.36          /*restore the state*/
    1.37          p->state = STATE_IORESP_READY;
     2.1 --- a/xen/include/asm-x86/vmx_virpit.h	Mon Jul 25 21:03:25 2005 +0000
     2.2 +++ b/xen/include/asm-x86/vmx_virpit.h	Mon Jul 25 21:03:40 2005 +0000
     2.3 @@ -19,6 +19,7 @@ struct vmx_virpit_t {
     2.4      /* for simulation of counter 0 in mode 2*/
     2.5      int vector;				/* the pit irq vector */
     2.6      unsigned int period;		/* the frequency. e.g. 10ms*/
     2.7 +    s_time_t scheduled;                 /* scheduled timer interrupt */
     2.8      unsigned int channel;		/* the pit channel, counter 0~2 */
     2.9      u64  *intr_bitmap;
    2.10      unsigned int pending_intr_nr;	/* the couner for pending timer interrupts */