Patch from: Tim Schmielau Fixes the problem wherein nanosleep() is sleeping for the wrong duration. When starting out with timer_jiffies=0, the timer cascade is (unneccessarily) triggered on the first timer interrupt, incrementing all the higher indices. When starting with any other initial jiffies value, we miss that and end up with all higher indices being off by one. kernel/timer.c | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff -puN kernel/timer.c~nanosleep-accuracy-fix kernel/timer.c --- 25/kernel/timer.c~nanosleep-accuracy-fix 2003-03-18 01:46:33.000000000 -0800 +++ 25-akpm/kernel/timer.c 2003-03-18 01:46:33.000000000 -0800 @@ -1200,10 +1200,14 @@ static void __devinit init_timers_cpu(in base->timer_jiffies = INITIAL_JIFFIES; base->tv1.index = INITIAL_JIFFIES & TVR_MASK; - base->tv2.index = (INITIAL_JIFFIES >> TVR_BITS) & TVN_MASK; - base->tv3.index = (INITIAL_JIFFIES >> (TVR_BITS+TVN_BITS)) & TVN_MASK; - base->tv4.index = (INITIAL_JIFFIES >> (TVR_BITS+2*TVN_BITS)) & TVN_MASK; - base->tv5.index = (INITIAL_JIFFIES >> (TVR_BITS+3*TVN_BITS)) & TVN_MASK; + base->tv2.index = ((INITIAL_JIFFIES >> TVR_BITS) + + (INITIAL_JIFFIES!=0)) & TVN_MASK; + base->tv3.index = ((INITIAL_JIFFIES >> (TVR_BITS+TVN_BITS)) + + (INITIAL_JIFFIES!=0)) & TVN_MASK; + base->tv4.index = ((INITIAL_JIFFIES >> (TVR_BITS+2*TVN_BITS)) + + (INITIAL_JIFFIES!=0)) & TVN_MASK; + base->tv5.index = ((INITIAL_JIFFIES >> (TVR_BITS+3*TVN_BITS)) + + (INITIAL_JIFFIES!=0)) & TVN_MASK; } static int __devinit timer_cpu_notify(struct notifier_block *self, _