ia64/xen-unstable

changeset 17533:013a47065e8c

x86 time: Read platform time before locally-extrapolated time during
calibration and frequency changes. This places the variable delay
(acquiring the platform_timer_lock) safely as the very first thing we
do, avoiding a variable delay /between/ computing the two timestamps.

Problem diagnosed by Dave Winchell <dwinchell@virtualiron.com>

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 01 09:45:44 2008 +0100 (2008-05-01)
parents 483d006cc607
children 1e169f4e8e72
files xen/arch/x86/time.c
line diff
     1.1 --- a/xen/arch/x86/time.c	Fri Apr 25 13:46:27 2008 +0100
     1.2 +++ b/xen/arch/x86/time.c	Thu May 01 09:45:44 2008 +0100
     1.3 @@ -759,12 +759,13 @@ int cpu_frequency_change(u64 freq)
     1.4      }
     1.5  
     1.6      local_irq_disable();
     1.7 -    rdtscll(curr_tsc);
     1.8 -    t->local_tsc_stamp = curr_tsc;
     1.9 +    /* Platform time /first/, as we may be delayed by platform_timer_lock. */
    1.10      t->stime_master_stamp = read_platform_stime();
    1.11      /* TSC-extrapolated time may be bogus after frequency change. */
    1.12      /*t->stime_local_stamp = get_s_time();*/
    1.13      t->stime_local_stamp = t->stime_master_stamp;
    1.14 +    rdtscll(curr_tsc);
    1.15 +    t->local_tsc_stamp = curr_tsc;
    1.16      set_time_scale(&t->tsc_scale, freq);
    1.17      local_irq_enable();
    1.18  
    1.19 @@ -834,11 +835,14 @@ static void local_time_calibration(void 
    1.20      prev_local_stime  = t->stime_local_stamp;
    1.21      prev_master_stime = t->stime_master_stamp;
    1.22  
    1.23 -    /* Disable IRQs to get 'instantaneous' current timestamps. */
    1.24 +    /*
    1.25 +     * Disable IRQs to get 'instantaneous' current timestamps. We read platform
    1.26 +     * time first, as we may be delayed when acquiring platform_timer_lock.
    1.27 +     */
    1.28      local_irq_disable();
    1.29 +    curr_master_stime = read_platform_stime();
    1.30 +    curr_local_stime  = get_s_time();
    1.31      rdtscll(curr_tsc);
    1.32 -    curr_local_stime  = get_s_time();
    1.33 -    curr_master_stime = read_platform_stime();
    1.34      local_irq_enable();
    1.35  
    1.36  #if 0