[PATCH] rebalancei from migration threads instead of from timer tick load_balancing has the potential of running for some time if f.e. sched_domains for a system with 1024 processors have to be balanced. We currently do all of that with interrupts disabled and this may result in long interrupts holdoffs. Most of that time is potentially spend in rebalance_tick. This patch splits off rebalance_tick from scheduler_tick and uses the migration threads to run schedule sched domain balancing as needed. If we run the balancing from the migration threads then we run with interrupts enabled so we need to change the request queue locking to disable interupts since the timer interrupt may require run queue locks during time slice processing (which we leave in the timer tick). Successfully completed a AIM7 run with it. Signed-off-by: Christoph Lameter Index: linux-2.6.19-rc2-mm2/kernel/sched.c =================================================================== --- linux-2.6.19-rc2-mm2.orig/kernel/sched.c 2006-10-23 21:35:09.000000000 -0500 +++ linux-2.6.19-rc2-mm2/kernel/sched.c 2006-10-23 21:54:17.336442731 -0500 @@ -3140,7 +3140,6 @@ void scheduler_tick(void) time_slice(rq, p); } update_load(rq); - rebalance_domains(cpu, rq); } #ifdef CONFIG_SCHED_SMT @@ -5006,6 +5005,7 @@ static int migration_thread(void *data) { int cpu = (long)data; struct rq *rq; + unsigned long next_domain_balance = jiffies + HZ / 2; rq = cpu_rq(cpu); BUG_ON(rq->migration_thread != current); @@ -5024,6 +5024,9 @@ static int migration_thread(void *data) goto wait_to_die; } + if (jiffies >= next_domain_balance) + next_domain_balance = rebalance_domains(cpu, rq); + if (rq->active_balance) { active_load_balance(rq, cpu); rq->active_balance = 0; @@ -5032,8 +5035,11 @@ static int migration_thread(void *data) head = &rq->migration_queue; if (list_empty(head)) { + int interval; + spin_unlock_irq(&rq->lock); - schedule(); + interval = next_domain_balance - jiffies; + schedule_timeout( (interval < 0) ? : interval); set_current_state(TASK_INTERRUPTIBLE); continue; }