diff options
author | Tejun Heo <tj@kernel.org> | 2012-04-01 15:09:54 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2012-04-01 15:09:54 -0400 |
commit | b0ca5a84fc3ad8f75bb2b7ac3dc6a77151cd3906 (patch) | |
tree | 87dcdec8c3104ed00b34518b4dc1837e8c03d837 /kernel/cgroup.c | |
parent | ff4c8d503e2583b485da46d0ec3dcc29639ab889 (diff) |
cgroup: build list of all cgroups under a given cgroupfs_root
Build a list of all cgroups anchored at cgroupfs_root->allcg_list and
going through cgroup->allcg_node. The list is protected by
cgroup_mutex and will be used to improve cgroup file handling.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 8f72853131d3..db4319c030d0 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -127,6 +127,9 @@ struct cgroupfs_root { | |||
127 | /* A list running through the active hierarchies */ | 127 | /* A list running through the active hierarchies */ |
128 | struct list_head root_list; | 128 | struct list_head root_list; |
129 | 129 | ||
130 | /* All cgroups on this root, cgroup_mutex protected */ | ||
131 | struct list_head allcg_list; | ||
132 | |||
130 | /* Hierarchy-specific flags */ | 133 | /* Hierarchy-specific flags */ |
131 | unsigned long flags; | 134 | unsigned long flags; |
132 | 135 | ||
@@ -1350,11 +1353,14 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp) | |||
1350 | static void init_cgroup_root(struct cgroupfs_root *root) | 1353 | static void init_cgroup_root(struct cgroupfs_root *root) |
1351 | { | 1354 | { |
1352 | struct cgroup *cgrp = &root->top_cgroup; | 1355 | struct cgroup *cgrp = &root->top_cgroup; |
1356 | |||
1353 | INIT_LIST_HEAD(&root->subsys_list); | 1357 | INIT_LIST_HEAD(&root->subsys_list); |
1354 | INIT_LIST_HEAD(&root->root_list); | 1358 | INIT_LIST_HEAD(&root->root_list); |
1359 | INIT_LIST_HEAD(&root->allcg_list); | ||
1355 | root->number_of_cgroups = 1; | 1360 | root->number_of_cgroups = 1; |
1356 | cgrp->root = root; | 1361 | cgrp->root = root; |
1357 | cgrp->top_cgroup = cgrp; | 1362 | cgrp->top_cgroup = cgrp; |
1363 | list_add_tail(&cgrp->allcg_node, &root->allcg_list); | ||
1358 | init_cgroup_housekeeping(cgrp); | 1364 | init_cgroup_housekeeping(cgrp); |
1359 | } | 1365 | } |
1360 | 1366 | ||
@@ -3790,6 +3796,8 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
3790 | /* The cgroup directory was pre-locked for us */ | 3796 | /* The cgroup directory was pre-locked for us */ |
3791 | BUG_ON(!mutex_is_locked(&cgrp->dentry->d_inode->i_mutex)); | 3797 | BUG_ON(!mutex_is_locked(&cgrp->dentry->d_inode->i_mutex)); |
3792 | 3798 | ||
3799 | list_add_tail(&cgrp->allcg_node, &root->allcg_list); | ||
3800 | |||
3793 | err = cgroup_populate_dir(cgrp); | 3801 | err = cgroup_populate_dir(cgrp); |
3794 | /* If err < 0, we have a half-filled directory - oh well ;) */ | 3802 | /* If err < 0, we have a half-filled directory - oh well ;) */ |
3795 | 3803 | ||
@@ -3998,6 +4006,8 @@ again: | |||
3998 | list_del_init(&cgrp->sibling); | 4006 | list_del_init(&cgrp->sibling); |
3999 | cgroup_unlock_hierarchy(cgrp->root); | 4007 | cgroup_unlock_hierarchy(cgrp->root); |
4000 | 4008 | ||
4009 | list_del_init(&cgrp->allcg_node); | ||
4010 | |||
4001 | d = dget(cgrp->dentry); | 4011 | d = dget(cgrp->dentry); |
4002 | 4012 | ||
4003 | cgroup_d_remove_dir(d); | 4013 | cgroup_d_remove_dir(d); |