aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64
diff options
context:
space:
mode:
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>2005-10-30 17:59:25 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 20:37:11 -0500
commitdacb16b1a034fa7a0b868ee30758119fbfd90bc1 (patch)
treedaaa631c9c6fa2ad011647fb3acd219784faf2e2 /arch/x86_64
parentbfd51626cbf61cb23f787d8ff972ef0d5ddacc0b (diff)
[PATCH] i386 and x86_64 TSC set_cyc2ns_scale imprecision
I just found out that some precision is unnecessarily lost in the arch/i386/kernel/timers/timer_tsc.c:set_cyc2ns_scale function. It uses a cpu_mhz parameter when it could use a cpu_khz. In the specific case of an Intel P4 running at 3001.171 Mhz, the truncation to 3001 Mhz leads to an imprecision of 19 microseconds per second : this is very sad for a timer with nearly nanosecond accuracy. Fix the x86_64 architecture too. Cc: george anzinger <george@mvista.com> Cc: john stultz <johnstul@us.ibm.com> Cc: Andi Kleen <ak@muc.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/x86_64')
-rw-r--r--arch/x86_64/kernel/time.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index 703acde2a1a5..47d25ad08160 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -481,9 +481,9 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
481static unsigned int cyc2ns_scale; 481static unsigned int cyc2ns_scale;
482#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */ 482#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
483 483
484static inline void set_cyc2ns_scale(unsigned long cpu_mhz) 484static inline void set_cyc2ns_scale(unsigned long cpu_khz)
485{ 485{
486 cyc2ns_scale = (1000 << CYC2NS_SCALE_FACTOR)/cpu_mhz; 486 cyc2ns_scale = (1000000 << CYC2NS_SCALE_FACTOR)/cpu_khz;
487} 487}
488 488
489static inline unsigned long long cycles_2_ns(unsigned long long cyc) 489static inline unsigned long long cycles_2_ns(unsigned long long cyc)
@@ -655,7 +655,7 @@ static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
655 vxtime.tsc_quot = (1000L << 32) / cpu_khz; 655 vxtime.tsc_quot = (1000L << 32) / cpu_khz;
656 } 656 }
657 657
658 set_cyc2ns_scale(cpu_khz_ref / 1000); 658 set_cyc2ns_scale(cpu_khz_ref);
659 659
660 return 0; 660 return 0;
661} 661}
@@ -939,7 +939,7 @@ void __init time_init(void)
939 rdtscll_sync(&vxtime.last_tsc); 939 rdtscll_sync(&vxtime.last_tsc);
940 setup_irq(0, &irq0); 940 setup_irq(0, &irq0);
941 941
942 set_cyc2ns_scale(cpu_khz / 1000); 942 set_cyc2ns_scale(cpu_khz);
943 943
944#ifndef CONFIG_SMP 944#ifndef CONFIG_SMP
945 time_init_gtod(); 945 time_init_gtod();