
From: Ingo Molnar <mingo@elte.hu>

I noticed on one of my boxes that enabling CONFIG_HPET reduces
sched_clock() accuracy quite drastically (whose precision is needed for
interactivity decisions, good balancing, etc.), because HPET does not
enable use_tsc.

The patch below fixes this by using the TSC in all cases where possible, 
even if TSC clocks may drift - sched_clock() drifting is being 
compensated for these days. So this patch will also improve precision on 
NUMA boxen. Plus, CONFIG_NUMA is not a guarantee for non-drifting TSCs 
anyway.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/i386/kernel/timers/timer_tsc.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff -puN arch/i386/kernel/timers/timer_tsc.c~sched-x86-sched_clock-to-use-tsc-on-config_hpet-or-config_numa-systems arch/i386/kernel/timers/timer_tsc.c
--- 25/arch/i386/kernel/timers/timer_tsc.c~sched-x86-sched_clock-to-use-tsc-on-config_hpet-or-config_numa-systems	2005-04-04 19:43:26.000000000 -0700
+++ 25-akpm/arch/i386/kernel/timers/timer_tsc.c	2005-04-04 19:43:26.000000000 -0700
@@ -133,18 +133,15 @@ static unsigned long long monotonic_cloc
 
 /*
  * Scheduler clock - returns current time in nanosec units.
+ *
+ * it's not a problem if the TSC is unsynchronized,
+ * as the scheduler will carefully compensate for it.
  */
 unsigned long long sched_clock(void)
 {
 	unsigned long long this_offset;
 
-	/*
-	 * In the NUMA case we dont use the TSC as they are not
-	 * synchronized across all CPUs.
-	 */
-#ifndef CONFIG_NUMA
-	if (!use_tsc)
-#endif
+	if (!cpu_has_tsc)
 		/* no locking but a rare wrong value is not a big deal */
 		return jiffies_64 * (1000000000 / HZ);
 
_
