Merge "sched/cgroup: Fix/cleanup cgroup teardown/init"
This commit is contained in:
commit
4de07155f9
3 changed files with 37 additions and 41 deletions
|
@ -8239,7 +8239,7 @@ void set_curr_task(int cpu, struct task_struct *p)
|
|||
/* task_group_lock serializes the addition/removal of task groups */
|
||||
static DEFINE_SPINLOCK(task_group_lock);
|
||||
|
||||
static void free_sched_group(struct task_group *tg)
|
||||
static void sched_free_group(struct task_group *tg)
|
||||
{
|
||||
free_fair_sched_group(tg);
|
||||
free_rt_sched_group(tg);
|
||||
|
@ -8265,7 +8265,7 @@ struct task_group *sched_create_group(struct task_group *parent)
|
|||
return tg;
|
||||
|
||||
err:
|
||||
free_sched_group(tg);
|
||||
sched_free_group(tg);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
|
@ -8285,27 +8285,24 @@ void sched_online_group(struct task_group *tg, struct task_group *parent)
|
|||
}
|
||||
|
||||
/* rcu callback to free various structures associated with a task group */
|
||||
static void free_sched_group_rcu(struct rcu_head *rhp)
|
||||
static void sched_free_group_rcu(struct rcu_head *rhp)
|
||||
{
|
||||
/* now it should be safe to free those cfs_rqs */
|
||||
free_sched_group(container_of(rhp, struct task_group, rcu));
|
||||
sched_free_group(container_of(rhp, struct task_group, rcu));
|
||||
}
|
||||
|
||||
/* Destroy runqueue etc associated with a task group */
|
||||
void sched_destroy_group(struct task_group *tg)
|
||||
{
|
||||
/* wait for possible concurrent references to cfs_rqs complete */
|
||||
call_rcu(&tg->rcu, free_sched_group_rcu);
|
||||
call_rcu(&tg->rcu, sched_free_group_rcu);
|
||||
}
|
||||
|
||||
void sched_offline_group(struct task_group *tg)
|
||||
{
|
||||
unsigned long flags;
|
||||
int i;
|
||||
|
||||
/* end participation in shares distribution */
|
||||
for_each_possible_cpu(i)
|
||||
unregister_fair_sched_group(tg, i);
|
||||
unregister_fair_sched_group(tg);
|
||||
|
||||
spin_lock_irqsave(&task_group_lock, flags);
|
||||
list_del_rcu(&tg->list);
|
||||
|
@ -8756,31 +8753,26 @@ cpu_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
|
|||
if (IS_ERR(tg))
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
sched_online_group(tg, parent);
|
||||
|
||||
return &tg->css;
|
||||
}
|
||||
|
||||
static int cpu_cgroup_css_online(struct cgroup_subsys_state *css)
|
||||
static void cpu_cgroup_css_released(struct cgroup_subsys_state *css)
|
||||
{
|
||||
struct task_group *tg = css_tg(css);
|
||||
struct task_group *parent = css_tg(css->parent);
|
||||
|
||||
if (parent)
|
||||
sched_online_group(tg, parent);
|
||||
return 0;
|
||||
sched_offline_group(tg);
|
||||
}
|
||||
|
||||
static void cpu_cgroup_css_free(struct cgroup_subsys_state *css)
|
||||
{
|
||||
struct task_group *tg = css_tg(css);
|
||||
|
||||
sched_destroy_group(tg);
|
||||
}
|
||||
|
||||
static void cpu_cgroup_css_offline(struct cgroup_subsys_state *css)
|
||||
{
|
||||
struct task_group *tg = css_tg(css);
|
||||
|
||||
sched_offline_group(tg);
|
||||
/*
|
||||
* Relies on the RCU grace period between css_released() and this.
|
||||
*/
|
||||
sched_free_group(tg);
|
||||
}
|
||||
|
||||
static void cpu_cgroup_fork(struct task_struct *task, void *private)
|
||||
|
@ -9147,9 +9139,8 @@ static struct cftype cpu_files[] = {
|
|||
|
||||
struct cgroup_subsys cpu_cgrp_subsys = {
|
||||
.css_alloc = cpu_cgroup_css_alloc,
|
||||
.css_released = cpu_cgroup_css_released,
|
||||
.css_free = cpu_cgroup_css_free,
|
||||
.css_online = cpu_cgroup_css_online,
|
||||
.css_offline = cpu_cgroup_css_offline,
|
||||
.fork = cpu_cgroup_fork,
|
||||
.can_attach = cpu_cgroup_can_attach,
|
||||
.attach = cpu_cgroup_attach,
|
||||
|
|
|
@ -9653,11 +9653,8 @@ void free_fair_sched_group(struct task_group *tg)
|
|||
for_each_possible_cpu(i) {
|
||||
if (tg->cfs_rq)
|
||||
kfree(tg->cfs_rq[i]);
|
||||
if (tg->se) {
|
||||
if (tg->se[i])
|
||||
remove_entity_load_avg(tg->se[i]);
|
||||
if (tg->se)
|
||||
kfree(tg->se[i]);
|
||||
}
|
||||
}
|
||||
|
||||
kfree(tg->cfs_rq);
|
||||
|
@ -9705,21 +9702,29 @@ err:
|
|||
return 0;
|
||||
}
|
||||
|
||||
void unregister_fair_sched_group(struct task_group *tg, int cpu)
|
||||
void unregister_fair_sched_group(struct task_group *tg)
|
||||
{
|
||||
struct rq *rq = cpu_rq(cpu);
|
||||
unsigned long flags;
|
||||
struct rq *rq;
|
||||
int cpu;
|
||||
|
||||
/*
|
||||
* Only empty task groups can be destroyed; so we can speculatively
|
||||
* check on_list without danger of it being re-added.
|
||||
*/
|
||||
if (!tg->cfs_rq[cpu]->on_list)
|
||||
return;
|
||||
for_each_possible_cpu(cpu) {
|
||||
if (tg->se[cpu])
|
||||
remove_entity_load_avg(tg->se[cpu]);
|
||||
|
||||
raw_spin_lock_irqsave(&rq->lock, flags);
|
||||
list_del_leaf_cfs_rq(tg->cfs_rq[cpu]);
|
||||
raw_spin_unlock_irqrestore(&rq->lock, flags);
|
||||
/*
|
||||
* Only empty task groups can be destroyed; so we can speculatively
|
||||
* check on_list without danger of it being re-added.
|
||||
*/
|
||||
if (!tg->cfs_rq[cpu]->on_list)
|
||||
continue;
|
||||
|
||||
rq = cpu_rq(cpu);
|
||||
|
||||
raw_spin_lock_irqsave(&rq->lock, flags);
|
||||
list_del_leaf_cfs_rq(tg->cfs_rq[cpu]);
|
||||
raw_spin_unlock_irqrestore(&rq->lock, flags);
|
||||
}
|
||||
}
|
||||
|
||||
void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
|
||||
|
@ -9801,7 +9806,7 @@ int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void unregister_fair_sched_group(struct task_group *tg, int cpu) { }
|
||||
void unregister_fair_sched_group(struct task_group *tg) { }
|
||||
|
||||
#endif /* CONFIG_FAIR_GROUP_SCHED */
|
||||
|
||||
|
|
|
@ -313,7 +313,7 @@ extern int tg_nop(struct task_group *tg, void *data);
|
|||
|
||||
extern void free_fair_sched_group(struct task_group *tg);
|
||||
extern int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent);
|
||||
extern void unregister_fair_sched_group(struct task_group *tg, int cpu);
|
||||
extern void unregister_fair_sched_group(struct task_group *tg);
|
||||
extern void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
|
||||
struct sched_entity *se, int cpu,
|
||||
struct sched_entity *parent);
|
||||
|
|
Loading…
Add table
Reference in a new issue