Fix up jiffy comparison function in the scheduler. The jiffy comparison in reblance_tick() has always used a simple integer comparison and I have followed that convention for the patchset that rebalances sched domains via a tasklet. However, jiffies may wrap around zero. If we do not use the time_after() function then comparisons may not give the intended results. Fix this up by using jiffy comparison functions. Signed-off-by: Christoph Lameter Index: linux-2.6.19-rc4-mm2/kernel/sched.c =================================================================== --- linux-2.6.19-rc4-mm2.orig/kernel/sched.c 2006-11-06 13:53:52.366233053 -0600 +++ linux-2.6.19-rc4-mm2/kernel/sched.c 2006-11-06 13:58:38.467745413 -0600 @@ -2766,8 +2766,10 @@ static void idle_balance(int this_cpu, s /* If we've pulled tasks over stop searching: */ pulled_task = load_balance_newidle(this_cpu, this_rq, sd); - next_balance = min(next_balance, - sd->last_balance + sd->balance_interval); + if (time_after(next_balance, + sd->last_balance + sd->balance_interval)) + next_balance = sd->last_balance + + sd->balance_interval; if (pulled_task) break; } @@ -2891,7 +2893,7 @@ static void rebalance_domains(unsigned l if (unlikely(!interval)) interval = 1; - if (jiffies - sd->last_balance >= interval) { + if (time_after_eq(jiffies, sd->last_balance + interval)) { if (load_balance(this_cpu, this_rq, sd, idle)) { /* * We've pulled tasks over so either we're no @@ -2910,8 +2912,8 @@ static void rebalance_domains(unsigned l * then idle_balance will reset next_balance so that we * rebalance earlier. */ - next_balance = min(next_balance, - sd->last_balance + interval); + if (time_after(next_balance, sd->last_balance + interval)) + next_balance = sd->last_balance + interval; } this_rq->next_balance = next_balance; } @@ -3168,7 +3170,7 @@ void scheduler_tick(void) task_running_tick(rq, p); #ifdef CONFIG_SMP update_load(rq); - if (jiffies >= rq->next_balance) + if (time_after_eq(jiffies, rq->next_balance)) tasklet_schedule(&rebalance); #endif }