summaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorTejun Heo2014-04-23 17:13:15 +0200
committerTejun Heo2014-04-23 17:13:15 +0200
commit3b281afbc3a06cd69c54e6db1a04a8e73997723f (patch)
treefe6fd8897b317f391ec7d2f55f7cb6f6370d8a7f /kernel/cgroup.c
parentcgroup: implement cgroup->e_csets[] (diff)
downloadkernel-qcow2-linux-3b281afbc3a06cd69c54e6db1a04a8e73997723f.tar.gz
kernel-qcow2-linux-3b281afbc3a06cd69c54e6db1a04a8e73997723f.tar.xz
kernel-qcow2-linux-3b281afbc3a06cd69c54e6db1a04a8e73997723f.zip
cgroup: make css_next_child() skip missing csses
css_next_child() walks the children of the specified css. It does this by finding the next cgroup and then returning the requested css. On the default unified hierarchy, a cgroup may not have a css associated with it even if the hierarchy has the subsystem enabled. This patch updates css_next_child() so that it skips children without the requested css associated. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 37d966289978..0edc186cd545 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2708,10 +2708,19 @@ css_next_child(struct cgroup_subsys_state *pos_css,
break;
}
- if (&next->sibling == &cgrp->children)
- return NULL;
+ /*
+ * @next, if not pointing to the head, can be dereferenced and is
+ * the next sibling; however, it might have @ss disabled. If so,
+ * fast-forward to the next enabled one.
+ */
+ while (&next->sibling != &cgrp->children) {
+ struct cgroup_subsys_state *next_css = cgroup_css(next, parent_css->ss);
- return cgroup_css(next, parent_css->ss);
+ if (next_css)
+ return next_css;
+ next = list_entry_rcu(next->sibling.next, struct cgroup, sibling);
+ }
+ return NULL;
}
/**