diff options
author | Li Zefan <lizefan@huawei.com> | 2013-01-24 01:30:48 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-01-24 15:05:18 -0500 |
commit | ace783b9bbfa2182b4a561498db3f09a0c56bc79 (patch) | |
tree | e490b561cbd0d14f6514f4f2cf1413bcab05c275 /include/linux | |
parent | fe1c06ca7523baa668c1eaf1e1016fa64753c32e (diff) |
sched: split out css_online/css_offline from tg creation/destruction
This is a preparaton for later patches.
- What do we gain from cpu_cgroup_css_online():
After ss->css_alloc() and before ss->css_online(), there's a small
window that tg->css.cgroup is NULL. With this change, tg won't be seen
before ss->css_online(), where it's added to the global list, so we're
guaranteed we'll never see NULL tg->css.cgroup.
- What do we gain from cpu_cgroup_css_offline():
tg is freed via RCU, so is cgroup. Without this change, This is how
synchronization works:
cgroup_rmdir()
no ss->css_offline()
diput()
syncornize_rcu()
ss->css_free() <-- unregister tg, and free it via call_rcu()
kfree_rcu(cgroup) <-- wait possible refs to cgroup, and free cgroup
We can't just kfree(cgroup), because tg might access tg->css.cgroup.
With this change:
cgroup_rmdir()
ss->css_offline() <-- unregister tg
diput()
synchronize_rcu() <-- wait possible refs to tg and cgroup
ss->css_free() <-- free tg
kfree_rcu(cgroup) <-- free cgroup
As you see, kfree_rcu() is redundant now.
Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/sched.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 206bb089c06b..577eb973de7a 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -2750,7 +2750,10 @@ extern void normalize_rt_tasks(void); | |||
2750 | extern struct task_group root_task_group; | 2750 | extern struct task_group root_task_group; |
2751 | 2751 | ||
2752 | extern struct task_group *sched_create_group(struct task_group *parent); | 2752 | extern struct task_group *sched_create_group(struct task_group *parent); |
2753 | extern void sched_online_group(struct task_group *tg, | ||
2754 | struct task_group *parent); | ||
2753 | extern void sched_destroy_group(struct task_group *tg); | 2755 | extern void sched_destroy_group(struct task_group *tg); |
2756 | extern void sched_offline_group(struct task_group *tg); | ||
2754 | extern void sched_move_task(struct task_struct *tsk); | 2757 | extern void sched_move_task(struct task_struct *tsk); |
2755 | #ifdef CONFIG_FAIR_GROUP_SCHED | 2758 | #ifdef CONFIG_FAIR_GROUP_SCHED |
2756 | extern int sched_group_set_shares(struct task_group *tg, unsigned long shares); | 2759 | extern int sched_group_set_shares(struct task_group *tg, unsigned long shares); |