提交 822ff793 编写于 作者: P Peter Zijlstra 提交者: Ingo Molnar

sched: Simplify the free path some

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: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Nick Piggin <npiggin@kernel.dk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20110407122942.298339503@chello.nlSigned-off-by: NIngo Molnar <mingo@elte.hu>
上级 dce840a0
...@@ -7023,7 +7023,8 @@ static void __free_domain_allocs(struct s_data *d, enum s_alloc what, ...@@ -7023,7 +7023,8 @@ static void __free_domain_allocs(struct s_data *d, enum s_alloc what,
switch (what) { switch (what) {
case sa_rootdomain: 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: case sa_sd:
free_percpu(d->sd); /* fall through */ free_percpu(d->sd); /* fall through */
case sa_sd_storage: case sa_sd_storage:
...@@ -7208,7 +7209,7 @@ static int build_sched_domains(const struct cpumask *cpu_map, ...@@ -7208,7 +7209,7 @@ static int build_sched_domains(const struct cpumask *cpu_map,
enum s_alloc alloc_state = sa_none; enum s_alloc alloc_state = sa_none;
struct sched_domain *sd; struct sched_domain *sd;
struct s_data d; struct s_data d;
int i; int i, ret = -ENOMEM;
alloc_state = __visit_domain_allocation_hell(&d, cpu_map); alloc_state = __visit_domain_allocation_hell(&d, cpu_map);
if (alloc_state != sa_rootdomain) if (alloc_state != sa_rootdomain)
...@@ -7261,12 +7262,10 @@ static int build_sched_domains(const struct cpumask *cpu_map, ...@@ -7261,12 +7262,10 @@ static int build_sched_domains(const struct cpumask *cpu_map,
} }
rcu_read_unlock(); rcu_read_unlock();
__free_domain_allocs(&d, sa_sd, cpu_map); ret = 0;
return 0;
error: error:
__free_domain_allocs(&d, alloc_state, cpu_map); __free_domain_allocs(&d, alloc_state, cpu_map);
return -ENOMEM; return ret;
} }
static cpumask_var_t *doms_cur; /* current sched domains */ static cpumask_var_t *doms_cur; /* current sched domains */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册