History

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.

Tejun Heo committed 14 years ago

Commit b0ca5a81 parent ff4c8d52 files · +12 −0Browse files

Showing the changes to kernel (1 of 2 files). Show all

Unified · Split

kernel/cgroup.c+10−0
@@ -127,6 +127,9 @@ struct cgroupfs_root { · 126 unmodified lines
127127 /* A list running through the active hierarchies */
128128 struct list_head root_list;
129129
130+ /* All cgroups on this root, cgroup_mutex protected */
131+ struct list_head allcg_list;
132+
130133 /* Hierarchy-specific flags */
131134 unsigned long flags;
132135
@@ -1350,11 +1353,14 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp) · 1217 unmodified lines
13501353 static void init_cgroup_root(struct cgroupfs_root *root)
13511354 {
13521355 struct cgroup *cgrp = &root->top_cgroup;
1356+
13531357 INIT_LIST_HEAD(&root->subsys_list);
13541358 INIT_LIST_HEAD(&root->root_list);
1359+ INIT_LIST_HEAD(&root->allcg_list);
13551360 root->number_of_cgroups = 1;
13561361 cgrp->root = root;
13571362 cgrp->top_cgroup = cgrp;
1363+ list_add_tail(&cgrp->allcg_node, &root->allcg_list);
13581364 init_cgroup_housekeeping(cgrp);
13591365 }
13601366
@@ -3790,6 +3796,8 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, · 2429 unmodified lines
37903796 /* The cgroup directory was pre-locked for us */
37913797 BUG_ON(!mutex_is_locked(&cgrp->dentry->d_inode->i_mutex));
37923798
3799+ list_add_tail(&cgrp->allcg_node, &root->allcg_list);
3800+
37933801 err = cgroup_populate_dir(cgrp);
37943802 /* If err < 0, we have a half-filled directory - oh well ;) */
37953803
@@ -3998,6 +4006,8 @@ again: · 202 unmodified lines
39984006 list_del_init(&cgrp->sibling);
39994007 cgroup_unlock_hierarchy(cgrp->root);
40004008
4009+ list_del_init(&cgrp->allcg_node);
4010+
40014011 d = dget(cgrp->dentry);
40024012
40034013 cgroup_d_remove_dir(d);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t