diff options
author | Tejun Heo <tj@kernel.org> | 2013-08-09 02:11:23 +0200 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-08-09 02:11:23 +0200 |
commit | 6387698699afd72d6304566fb6ccf84bffe07c56 (patch) | |
tree | 9440e96fa8e5adce62409a5b0e40984dfedaada3 /net | |
parent | cgroup: add/update accessors which obtain subsys specific data from css (diff) | |
download | linux-6387698699afd72d6304566fb6ccf84bffe07c56.tar.xz linux-6387698699afd72d6304566fb6ccf84bffe07c56.zip |
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 'net')
-rw-r--r-- | net/sched/cls_cgroup.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c index af412ab2b477..9e6b75e5efce 100644 --- a/net/sched/cls_cgroup.c +++ b/net/sched/cls_cgroup.c @@ -50,9 +50,11 @@ static struct cgroup_subsys_state *cgrp_css_alloc(struct cgroup *cgrp) static int cgrp_css_online(struct cgroup *cgrp) { - if (cgrp->parent) - cgrp_cls_state(cgrp)->classid = - cgrp_cls_state(cgrp->parent)->classid; + struct cgroup_cls_state *cs = cgrp_cls_state(cgrp); + struct cgroup_cls_state *parent = css_cls_state(css_parent(&cs->css)); + + if (parent) + cs->classid = parent->classid; return 0; } |