cgroup: distinguish local and children populated states

cgrp->populated_cnt counts both local (the cgroup's populated
css_sets) and subtree proper (populated children) so that it's only
zero when the whole subtree, including self, is empty.

This patch splits the counter into two so that local and children
populated states are tracked separately.  It allows finer-grained
tests on the state of the hierarchy which will be used to replace
css_set walking local populated test.

Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
Tejun Heo
2017-07-16 21:43:33 -04:00
parent 88e033e326
commit 788b950c62
3 changed files with 31 additions and 21 deletions

View File

@@ -537,7 +537,7 @@ static inline bool task_under_cgroup_hierarchy(struct task_struct *task,
/* no synchronization, the result can only be used as a hint */
static inline bool cgroup_is_populated(struct cgroup *cgrp)
{
return cgrp->populated_cnt;
return cgrp->nr_populated_csets + cgrp->nr_populated_children;
}
/* returns ino associated with a cgroup */