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.
Showing the changes to kernel (1 of 2 files). Show all
Unified · Split
| @@ -127,6 +127,9 @@ struct cgroupfs_root { · 126 unmodified lines | ||
| 127 | 127 | /* A list running through the active hierarchies */ |
| 128 | 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 | 133 | /* Hierarchy-specific flags */ |
| 131 | 134 | unsigned long flags; |
| 132 | 135 | |
| @@ -1350,11 +1353,14 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp) · 1217 unmodified lines | ||
| 1350 | 1353 | static void init_cgroup_root(struct cgroupfs_root *root) |
| 1351 | 1354 | { |
| 1352 | 1355 | struct cgroup *cgrp = &root->top_cgroup; |
| 1356 | + | |
| 1353 | 1357 | INIT_LIST_HEAD(&root->subsys_list); |
| 1354 | 1358 | INIT_LIST_HEAD(&root->root_list); |
| 1359 | + INIT_LIST_HEAD(&root->allcg_list); | |
| 1355 | 1360 | root->number_of_cgroups = 1; |
| 1356 | 1361 | cgrp->root = root; |
| 1357 | 1362 | cgrp->top_cgroup = cgrp; |
| 1363 | + list_add_tail(&cgrp->allcg_node, &root->allcg_list); | |
| 1358 | 1364 | init_cgroup_housekeeping(cgrp); |
| 1359 | 1365 | } |
| 1360 | 1366 | |
| @@ -3790,6 +3796,8 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, · 2429 unmodified lines | ||
| 3790 | 3796 | /* The cgroup directory was pre-locked for us */ |
| 3791 | 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 | 3801 | err = cgroup_populate_dir(cgrp); |
| 3794 | 3802 | /* If err < 0, we have a half-filled directory - oh well ;) */ |
| 3795 | 3803 | |
| @@ -3998,6 +4006,8 @@ again: · 202 unmodified lines | ||
| 3998 | 4006 | list_del_init(&cgrp->sibling); |
| 3999 | 4007 | cgroup_unlock_hierarchy(cgrp->root); |
| 4000 | 4008 | |
| 4009 | + list_del_init(&cgrp->allcg_node); | |
| 4010 | + | |
| 4001 | 4011 | d = dget(cgrp->dentry); |
| 4002 | 4012 | |
| 4003 | 4013 | cgroup_d_remove_dir(d); |