sched_clock: record TSC after gtod
authorSteven Rostedt <[email protected]>
Wed, 9 Jul 2008 04:15:32 +0000 (00:15 -0400)
committerIngo Molnar <[email protected]>
Fri, 11 Jul 2008 13:53:27 +0000 (15:53 +0200)
To read the gtod we need to grab the xtime lock for read. Reading the gtod
before the TSC can cause a bigger gab if the xtime lock is contended.

This patch simply reverses the order to read the TSC after the gtod.
The locking in the reading of the gtod handles any barriers one might
think is needed.

Signed-off-by: Steven Rostedt <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: john stultz <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
kernel/sched_clock.c

index ee7cce5029ce9cf8c5c53255d21f3f5c3e916b85..28ff6bf5e02b9697657bed07941a98ddae88fa0e 100644 (file)
@@ -237,8 +237,8 @@ void sched_clock_tick(void)
 
        WARN_ON_ONCE(!irqs_disabled());
 
-       now = sched_clock();
        now_gtod = ktime_to_ns(ktime_get());
+       now = sched_clock();
 
        __raw_spin_lock(&scd->lock);
        __update_sched_clock(scd, now, NULL);