Skip to content

Commit 16f3ef4

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
sched/core: Restructure destroy_sched_domain()
There is no point in doing a call_rcu() for each domain, only do a callback for the root sched domain and clean up the entire set in one go. Also make the entire call chain be called destroy_sched_domain*() to remove confusion with the free_sched_domains() call, which does an entirely different thing. Both cpu_attach_domain() callers of destroy_sched_domain() can live without the call_rcu() because at those points the sched_domain hasn't been published yet. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent f39180e commit 16f3ef4

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

kernel/sched/core.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5935,10 +5935,8 @@ static void free_sched_groups(struct sched_group *sg, int free_sgc)
59355935
} while (sg != first);
59365936
}
59375937

5938-
static void free_sched_domain(struct rcu_head *rcu)
5938+
static void destroy_sched_domain(struct sched_domain *sd)
59395939
{
5940-
struct sched_domain *sd = container_of(rcu, struct sched_domain, rcu);
5941-
59425940
/*
59435941
* If its an overlapping domain it has private groups, iterate and
59445942
* nuke them all.
@@ -5952,15 +5950,21 @@ static void free_sched_domain(struct rcu_head *rcu)
59525950
kfree(sd);
59535951
}
59545952

5955-
static void destroy_sched_domain(struct sched_domain *sd)
5953+
static void destroy_sched_domains_rcu(struct rcu_head *rcu)
59565954
{
5957-
call_rcu(&sd->rcu, free_sched_domain);
5955+
struct sched_domain *sd = container_of(rcu, struct sched_domain, rcu);
5956+
5957+
while (sd) {
5958+
struct sched_domain *parent = sd->parent;
5959+
destroy_sched_domain(sd);
5960+
sd = parent;
5961+
}
59585962
}
59595963

59605964
static void destroy_sched_domains(struct sched_domain *sd)
59615965
{
5962-
for (; sd; sd = sd->parent)
5963-
destroy_sched_domain(sd);
5966+
if (sd)
5967+
call_rcu(&sd->rcu, destroy_sched_domains_rcu);
59645968
}
59655969

59665970
/*

0 commit comments

Comments
 (0)