[RFC][PATCH] linux-2.4.23-pre9_cyclone-lpj-fix_A0

From: john stultz
Date: Mon Nov 03 2003 - 17:36:10 EST


Marcelo, All,
In working to resolve an issue in SLES8 SP3, Andrea caught a bug in the
cyclone counter's lost-tick compensation code. In the code, we use the
calibrated loops_per_jiffies to detect the number of ticks that have
passed, however the lost-ticks code begins running before
loops_per_jiffies is calculated. This circular dependency that can cause
loops_per_jiffies to be occasionally mis-calculated.

The fix drops use of loops_per_jiffies and uses code from 2.5 to do the
same thing. This patch only affects x440/x445 machines.

Many thanks for Andrea for catching this.

Any comments and feedback on the patch is welcome.

thanks
-john

diff -Nru a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
--- a/arch/i386/kernel/time.c Mon Nov 3 13:47:16 2003
+++ b/arch/i386/kernel/time.c Mon Nov 3 13:47:16 2003
@@ -279,6 +279,7 @@
static inline void mark_timeoffset_cyclone(void)
{
int count;
+ unsigned long lost;
unsigned long delta = last_cyclone_timer;
spin_lock(&i8253_lock);
/* quickly read the cyclone timer */
@@ -293,11 +294,12 @@
spin_unlock(&i8253_lock);

/*lost tick compensation*/
- delta = last_cyclone_timer - delta;
- if(delta > loops_per_jiffy+2000){
- delta = (delta/loops_per_jiffy)-1;
- jiffies += delta;
- }
+ delta = last_cyclone_timer - delta;
+ delta /= (CYCLONE_TIMER_FREQ/1000000);
+ delta += delay_at_last_interrupt;
+ lost = delta/(1000000/HZ);
+ if (lost >= 2)
+ jiffies += lost-1;

count = ((LATCH-1) - count) * TICK_SIZE;
delay_at_last_interrupt = (count + LATCH/2) / LATCH;



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/