diff options
author | Tejun Heo | 2014-02-13 12:58:39 +0100 |
---|---|---|
committer | Tejun Heo | 2014-02-13 12:58:39 +0100 |
commit | 07bc356ed2950048d33d667e933e1b913c6e6b6d (patch) | |
tree | 5efb91f14c21157285965cfcbf480a3538dda35e /include/linux | |
parent | cgroup: relocate cgroup_enable_task_cg_lists() (diff) | |
download | kernel-qcow2-linux-07bc356ed2950048d33d667e933e1b913c6e6b6d.tar.gz kernel-qcow2-linux-07bc356ed2950048d33d667e933e1b913c6e6b6d.tar.xz kernel-qcow2-linux-07bc356ed2950048d33d667e933e1b913c6e6b6d.zip |
cgroup: implement cgroup_has_tasks() and unexport cgroup_task_count()
cgroup_task_count() read-locks css_set_lock and walks all tasks to
count them and then returns the result. The only thing all the users
want is determining whether the cgroup is empty or not. This patch
implements cgroup_has_tasks() which tests whether cgroup->cset_links
is empty, replaces all cgroup_task_count() usages and unexports it.
Note that the test isn't synchronized. This is the same as before.
The test has always been racy.
This will help planned css_set locking update.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/cgroup.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index e2ffcdc26cb7..72154fb44fb5 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -457,6 +457,12 @@ static inline bool cgroup_sane_behavior(const struct cgroup *cgrp) return cgrp->root->flags & CGRP_ROOT_SANE_BEHAVIOR; } +/* no synchronization, the result can only be used as a hint */ +static inline bool cgroup_has_tasks(struct cgroup *cgrp) +{ + return !list_empty(&cgrp->cset_links); +} + /* returns ino associated with a cgroup, 0 indicates unmounted root */ static inline ino_t cgroup_ino(struct cgroup *cgrp) { @@ -516,8 +522,6 @@ int cgroup_rm_cftypes(struct cftype *cfts); bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor); -int cgroup_task_count(const struct cgroup *cgrp); - /* * Control Group taskset, used to pass around set of tasks to cgroup_subsys * methods. |