[PATCH][x86-64] fix pit delay accounting in timer_interrupt()

From: Avi Kivity
Date: Mon Feb 28 2005 - 08:54:43 EST


timer_interrupt() measures the delay from an interrupt to its handling
in a variable called 'delay', but accounts every unit of delay as 1/HZ
seconds, instead of 1/CLOCK_TICK_RATE seconds.

on ordinary cpus this doesn't matter as delay is usually zero, but on my
10MHz bochs cpu this causes divide overflows later on.

(patch against 2.6.9 but should apply)

Signed-off-by: Avi Kivity <avi@xxxxxxxxxx>


--- linux-2.6.9/arch/x86_64/kernel/time.c~time 2005-02-28 14:26:52.000000000 +0200
+++ linux-2.6.9/arch/x86_64/kernel/time.c 2005-02-28 14:28:46.000000000 +0200
@@ -409,7 +409,7 @@

monotonic_base += (tsc - vxtime.last_tsc)*1000000/cpu_khz ;

- vxtime.last_tsc = tsc - vxtime.quot * delay / vxtime.tsc_quot;
+ vxtime.last_tsc = tsc - vxtime.quot * delay / (LATCH * vxtime.tsc_quot);

if ((((tsc - vxtime.last_tsc) *
vxtime.tsc_quot) >> 32) < offset)