diff options
author | Tejun Heo <tj@kernel.org> | 2013-08-08 20:11:23 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-08-08 20:11:23 -0400 |
commit | 6387698699afd72d6304566fb6ccf84bffe07c56 (patch) | |
tree | 9440e96fa8e5adce62409a5b0e40984dfedaada3 /kernel/sched/core.c | |
parent | a7c6d554aa01236ac2a9f851ab0f75704f76dfa2 (diff) |
cgroup: add css_parent()
Currently, controllers have to explicitly follow the cgroup hierarchy
to find the parent of a given css. cgroup is moving towards using
cgroup_subsys_state as the main controller interface construct, so
let's provide a way to climb the hierarchy using just csses.
This patch implements css_parent() which, given a css, returns its
parent. The function is guarnateed to valid non-NULL parent css as
long as the target css is not at the top of the hierarchy.
freezer, cpuset, cpu, cpuacct, hugetlb, memory, net_cls and devices
are converted to use css_parent() instead of accessing cgroup->parent
directly.
* __parent_ca() is dropped from cpuacct and its usage is replaced with
parent_ca(). The only difference between the two was NULL test on
cgroup->parent which is now embedded in css_parent() making the
distinction moot. Note that eventually a css->parent field will be
added to css and the NULL check in css_parent() will go away.
This patch shouldn't cause any behavior differences.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r-- | kernel/sched/core.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 5bccb0277129..7a10742b389a 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
@@ -7114,13 +7114,10 @@ static struct cgroup_subsys_state *cpu_cgroup_css_alloc(struct cgroup *cgrp) | |||
7114 | static int cpu_cgroup_css_online(struct cgroup *cgrp) | 7114 | static int cpu_cgroup_css_online(struct cgroup *cgrp) |
7115 | { | 7115 | { |
7116 | struct task_group *tg = cgroup_tg(cgrp); | 7116 | struct task_group *tg = cgroup_tg(cgrp); |
7117 | struct task_group *parent; | 7117 | struct task_group *parent = css_tg(css_parent(&tg->css)); |
7118 | 7118 | ||
7119 | if (!cgrp->parent) | 7119 | if (parent) |
7120 | return 0; | 7120 | sched_online_group(tg, parent); |
7121 | |||
7122 | parent = cgroup_tg(cgrp->parent); | ||
7123 | sched_online_group(tg, parent); | ||
7124 | return 0; | 7121 | return 0; |
7125 | } | 7122 | } |
7126 | 7123 | ||