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

Appended patch removes the unnecessary scheduler domains(containing only
one sched group) setup during the sched-domain init.

For example on x86_64, we always have NUMA configured in.  On Intel EM64T
systems, top most sched domain will be of NUMA and with only one
sched_group in it.  

With fork/exec balances(recent Nick's fixes in -mm tree), we always endup
taking wrong decisions because of this topmost domain (as it contains only
one group and find_idlest_group always returns NULL).  We will endup
loading HT package completely first, letting active load balance kickin and
correct it.

In general, this patch also makes sense with out recent Nick's fixes
in -mm.

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/kernel/sched.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+)

diff -puN kernel/sched.c~sched-remove-unnecessary-sched-domains kernel/sched.c
--- 25/kernel/sched.c~sched-remove-unnecessary-sched-domains	2005-04-01 20:31:58.000000000 -0800
+++ 25-akpm/kernel/sched.c	2005-04-01 20:31:58.000000000 -0800
@@ -4750,6 +4750,21 @@ void __devinit cpu_attach_domain(struct 
 	unsigned long flags;
 	runqueue_t *rq = cpu_rq(cpu);
 	int local = 1;
+	struct sched_domain *tmp = sd, *tmp1;
+
+	/* Remove the sched domains which has only one group
+	 */
+	while (tmp) {
+		tmp1 = tmp->parent;
+		if (!tmp1)
+			break;
+		if (tmp1->groups == tmp1->groups->next)
+			tmp->parent = tmp1->parent;
+		tmp = tmp->parent;
+	}
+
+	if (sd->parent && sd->groups && sd->groups == sd->groups->next)
+		sd = sd->parent;
 
 	sched_domain_debug(sd, cpu);
 
_
