From: "Siddha, Suresh B" <suresh.b.siddha@intel.com>

Jack Steiner brought this issue at my OLS talk.

Take a scenario where two tasks are pinned to two HT threads in a physical
package.  Idle packages in the system will keep kicking migration_thread on
the busy package with out any success.

We will run into similar scenarios in the presence of CMP/NUMA.

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 kernel/sched.c |   11 +++++++++++
 1 files changed, 11 insertions(+)

diff -puN kernel/sched.c~sched-dont-kick-alb-in-the-presence-of-pinned-task kernel/sched.c
--- devel/kernel/sched.c~sched-dont-kick-alb-in-the-presence-of-pinned-task	2005-08-21 23:49:39.000000000 -0700
+++ devel-akpm/kernel/sched.c	2005-08-21 23:49:39.000000000 -0700
@@ -2220,6 +2220,16 @@ static int load_balance(int this_cpu, ru
 		if (unlikely(sd->nr_balance_failed > sd->cache_nice_tries+2)) {
 
 			spin_lock(&busiest->lock);
+
+			/* don't kick the migration_thread, if the curr
+			 * task on busiest cpu can't be moved to this_cpu
+			 */
+			if (!cpu_isset(this_cpu, busiest->curr->cpus_allowed)) {
+				spin_unlock(&busiest->lock);
+				all_pinned = 1;
+				goto out_one_pinned;
+			}
+
 			if (!busiest->active_balance) {
 				busiest->active_balance = 1;
 				busiest->push_cpu = this_cpu;
@@ -2257,6 +2267,7 @@ static int load_balance(int this_cpu, ru
 out_balanced:
 	spin_unlock(&this_rq->lock);
 
+out_one_pinned:
 	schedstat_inc(sd, lb_balanced[idle]);
 
 	sd->nr_balance_failed = 0;
_