[RFC][PATCH 10/14] sched: Simplify the free path some

From: Peter Zijlstra
Date: Mon Mar 14 2011 - 11:28:07 EST


If we check the root_domain reference count we can see if its been
used or not, use this observation to simplify some of the return
paths.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
LKML-Reference: <new-submission>
---
kernel/sched.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

Index: linux-2.6/kernel/sched.c
===================================================================
--- linux-2.6.orig/kernel/sched.c
+++ linux-2.6/kernel/sched.c
@@ -6999,7 +6999,8 @@ static void __free_domain_allocs(struct

switch (what) {
case sa_rootdomain:
- free_rootdomain(&d->rd->rcu); /* fall through */
+ if (!atomic_read(&d->rd->refcount))
+ free_rootdomain(&d->rd->rcu); /* fall through */
case sa_sd:
free_percpu(d->sd); /* fall through */
case sa_sd_storage:
@@ -7184,7 +7185,7 @@ static int __build_sched_domains(const s
enum s_alloc alloc_state = sa_none;
struct sched_domain *sd;
struct s_data d;
- int i;
+ int i, ret = -ENOMEM;

alloc_state = __visit_domain_allocation_hell(&d, cpu_map);
if (alloc_state != sa_rootdomain)
@@ -7236,12 +7237,10 @@ static int __build_sched_domains(const s
sched_domain_debug(sd, i);
}

- __free_domain_allocs(&d, sa_sd, cpu_map);
- return 0;
-
+ ret = 0;
error:
__free_domain_allocs(&d, alloc_state, cpu_map);
- return -ENOMEM;
+ return ret;
}

static int build_sched_domains(const struct cpumask *cpu_map)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/