OSDN Git Service

cgroup: rename cgroupfs_root->number_of_cgroups to ->nr_cgrps and make it atomic_t
authorTejun Heo <tj@kernel.org>
Wed, 12 Feb 2014 14:29:50 +0000 (09:29 -0500)
committerTejun Heo <tj@kernel.org>
Wed, 12 Feb 2014 14:29:50 +0000 (09:29 -0500)
commit3c9c825b8b50de7dbb015e6bfc04bb2da79364d9
treed12fdc2cc0c232e07f1cccb1f72435210e18075e
parente61734c55c24cdf11b07e52a74aec4dc4a7f4bd0
cgroup: rename cgroupfs_root->number_of_cgroups to ->nr_cgrps and make it atomic_t

root->number_of_cgroups is currently an integer protected with
cgroup_mutex.  Except for sanity checks and proc reporting, the only
place it's used is to check whether the root has any child during
remount; however, this is a bit flawed as the counter is not
decremented when the cgroup is unlinked but when it's released,
meaning that there could be an extended period where all cgroups are
removed but remount is still not allowed because some internal objects
are lingering.  While not perfect either, it'd be better to use
emptiness test on root->top_cgroup.children.

This patch updates cgroup_remount() to test top_cgroup's children
instead, which makes number_of_cgroups only actual usage statistics
printing in proc implemented in proc_cgroupstats_show().  Let's
shorten its name and make it an atomic_t so that we don't have to
worry about its synchronization.  It's purely auxiliary at this point.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
include/linux/cgroup.h
kernel/cgroup.c