]> xenbits.xensource.com Git - xen.git/commitdiff
x86 time: Read platform time before locally-extrapolated time during
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 1 May 2008 08:45:44 +0000 (09:45 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 1 May 2008 08:45:44 +0000 (09:45 +0100)
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>
xen/arch/x86/time.c

index ccefc50cf2cb94de5afb6de9c328c2db0b0d5ef6..6bec5cb1c6ff6ad706c965ba92638762feec705b 100644 (file)
@@ -759,12 +759,13 @@ int cpu_frequency_change(u64 freq)
     }
 
     local_irq_disable();
-    rdtscll(curr_tsc);
-    t->local_tsc_stamp = curr_tsc;
+    /* Platform time /first/, as we may be delayed by platform_timer_lock. */
     t->stime_master_stamp = read_platform_stime();
     /* TSC-extrapolated time may be bogus after frequency change. */
     /*t->stime_local_stamp = get_s_time();*/
     t->stime_local_stamp = t->stime_master_stamp;
+    rdtscll(curr_tsc);
+    t->local_tsc_stamp = curr_tsc;
     set_time_scale(&t->tsc_scale, freq);
     local_irq_enable();
 
@@ -834,11 +835,14 @@ static void local_time_calibration(void *unused)
     prev_local_stime  = t->stime_local_stamp;
     prev_master_stime = t->stime_master_stamp;
 
-    /* Disable IRQs to get 'instantaneous' current timestamps. */
+    /*
+     * Disable IRQs to get 'instantaneous' current timestamps. We read platform
+     * time first, as we may be delayed when acquiring platform_timer_lock.
+     */
     local_irq_disable();
-    rdtscll(curr_tsc);
-    curr_local_stime  = get_s_time();
     curr_master_stime = read_platform_stime();
+    curr_local_stime  = get_s_time();
+    rdtscll(curr_tsc);
     local_irq_enable();
 
 #if 0