* Rusty Russell wrote: > Looking through 2.6.8.1-mm1, I see this code which doesn't make sense: > So, first off, the statements under "if (unlikely(cpu != this_cpu))" > can be folded into the previous block, since that's under the same > test. Secondly, why is sleep_avg being set twice to the same thing, > and why are we happy to adjust it the first time without holding the > rq lock for current, but the second time we make sure we are holding > the rq lock? [...] agreed, this is a bug - the code has rotten somewhat. The attached patch fixes it. I've also cleaned up the locking and added this_rq, to make clear when and how we are hopping from one runqueue to another. (this cleanup would have made the original bug more obvious as well.) This comes after sched-nonlinear-timeslicespatch.patch in 2.6.8.1-mm1. Tested on x86. > [...] recalc_task_prio seems happy to adjust a tasks ->sleep_avg > without holding any lock at all... this is not true - we always update ->avg_sleep while holding the lock. recalc_task_prio() is stricly called with p's runqueue lock held. Ingo