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>
Showing
- block/blk-cgroup.h 1 addition, 3 deletionsblock/blk-cgroup.h
- include/linux/cgroup.h 15 additions, 0 deletionsinclude/linux/cgroup.h
- kernel/cgroup_freezer.c 2 additions, 6 deletionskernel/cgroup_freezer.c
- kernel/cpuset.c 1 addition, 5 deletionskernel/cpuset.c
- kernel/sched/core.c 3 additions, 6 deletionskernel/sched/core.c
- kernel/sched/cpuacct.c 2 additions, 9 deletionskernel/sched/cpuacct.c
- mm/hugetlb_cgroup.c 1 addition, 5 deletionsmm/hugetlb_cgroup.c
- mm/memcontrol.c 11 additions, 28 deletionsmm/memcontrol.c
- net/sched/cls_cgroup.c 5 additions, 3 deletionsnet/sched/cls_cgroup.c
- security/device_cgroup.c 5 additions, 13 deletionssecurity/device_cgroup.c
Loading
Please register or sign in to comment