From: Andrew Morton Cc: "Chen, Kenneth W" Cc: Ingo Molnar Cc: Con Kolivas Signed-off-by: Andrew Morton --- kernel/sched.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff -puN kernel/sched.c~sched-fix-smt-nice-lock-contention-and-optimization-tidy kernel/sched.c --- devel/kernel/sched.c~sched-fix-smt-nice-lock-contention-and-optimization-tidy 2006-06-09 15:22:28.000000000 -0700 +++ devel-akpm/kernel/sched.c 2006-06-09 15:22:28.000000000 -0700 @@ -1099,9 +1099,10 @@ static int sched_balance_self(int cpu, i struct task_struct *t = current; struct sched_domain *tmp, *sd = NULL; - for_each_domain(cpu, tmp) + for_each_domain(cpu, tmp) { if (tmp->flags & flag) sd = tmp; + } while (sd) { cpumask_t span; @@ -2375,10 +2376,11 @@ static void active_load_balance(runqueue double_lock_balance(busiest_rq, target_rq); /* Search for an sd spanning us and the target CPU. */ - for_each_domain(target_cpu, sd) + for_each_domain(target_cpu, sd) { if ((sd->flags & SD_LOAD_BALANCE) && cpu_isset(busiest_cpu, sd->span)) break; + } if (unlikely(sd == NULL)) goto out; @@ -2722,11 +2724,13 @@ static void wake_sleeping_dependent(int struct sched_domain *tmp, *sd = NULL; int i; - for_each_domain(this_cpu, tmp) + for_each_domain(this_cpu, tmp) { if (tmp->flags & SD_SHARE_CPUPOWER) { sd = tmp; break; } + } + if (!sd) return; @@ -2768,11 +2772,13 @@ static int dependent_sleeper(int this_cp if (!p->mm || rt_task(p)) return 0; - for_each_domain(this_cpu, tmp) + for_each_domain(this_cpu, tmp) { if (tmp->flags & SD_SHARE_CPUPOWER) { sd = tmp; break; } + } + if (!sd) return 0; @@ -6156,7 +6162,7 @@ void normalize_rt_tasks(void) runqueue_t *rq; read_lock_irq(&tasklist_lock); - for_each_process (p) { + for_each_process(p) { if (!rt_task(p)) continue; _