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>
This commit is contained in:
		
					parent
					
						
							
								ff4c8d503e
							
						
					
				
			
			
				commit
				
					
						b0ca5a84fc
					
				
			
		
					 2 changed files with 12 additions and 0 deletions
				
			
		| 
						 | 
					@ -191,6 +191,8 @@ struct cgroup {
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	struct list_head css_sets;
 | 
						struct list_head css_sets;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct list_head allcg_node;	/* cgroupfs_root->allcg_list */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Linked list running through all cgroups that can
 | 
						 * Linked list running through all cgroups that can
 | 
				
			||||||
	 * potentially be reaped by the release agent. Protected by
 | 
						 * potentially be reaped by the release agent. Protected by
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -127,6 +127,9 @@ struct cgroupfs_root {
 | 
				
			||||||
	/* A list running through the active hierarchies */
 | 
						/* A list running through the active hierarchies */
 | 
				
			||||||
	struct list_head root_list;
 | 
						struct list_head root_list;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* All cgroups on this root, cgroup_mutex protected */
 | 
				
			||||||
 | 
						struct list_head allcg_list;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Hierarchy-specific flags */
 | 
						/* Hierarchy-specific flags */
 | 
				
			||||||
	unsigned long flags;
 | 
						unsigned long flags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1350,11 +1353,14 @@ static void init_cgroup_housekeeping(struct cgroup *cgrp)
 | 
				
			||||||
static void init_cgroup_root(struct cgroupfs_root *root)
 | 
					static void init_cgroup_root(struct cgroupfs_root *root)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cgroup *cgrp = &root->top_cgroup;
 | 
						struct cgroup *cgrp = &root->top_cgroup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	INIT_LIST_HEAD(&root->subsys_list);
 | 
						INIT_LIST_HEAD(&root->subsys_list);
 | 
				
			||||||
	INIT_LIST_HEAD(&root->root_list);
 | 
						INIT_LIST_HEAD(&root->root_list);
 | 
				
			||||||
 | 
						INIT_LIST_HEAD(&root->allcg_list);
 | 
				
			||||||
	root->number_of_cgroups = 1;
 | 
						root->number_of_cgroups = 1;
 | 
				
			||||||
	cgrp->root = root;
 | 
						cgrp->root = root;
 | 
				
			||||||
	cgrp->top_cgroup = cgrp;
 | 
						cgrp->top_cgroup = cgrp;
 | 
				
			||||||
 | 
						list_add_tail(&cgrp->allcg_node, &root->allcg_list);
 | 
				
			||||||
	init_cgroup_housekeeping(cgrp);
 | 
						init_cgroup_housekeeping(cgrp);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3790,6 +3796,8 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
 | 
				
			||||||
	/* The cgroup directory was pre-locked for us */
 | 
						/* The cgroup directory was pre-locked for us */
 | 
				
			||||||
	BUG_ON(!mutex_is_locked(&cgrp->dentry->d_inode->i_mutex));
 | 
						BUG_ON(!mutex_is_locked(&cgrp->dentry->d_inode->i_mutex));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						list_add_tail(&cgrp->allcg_node, &root->allcg_list);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = cgroup_populate_dir(cgrp);
 | 
						err = cgroup_populate_dir(cgrp);
 | 
				
			||||||
	/* If err < 0, we have a half-filled directory - oh well ;) */
 | 
						/* If err < 0, we have a half-filled directory - oh well ;) */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3998,6 +4006,8 @@ again:
 | 
				
			||||||
	list_del_init(&cgrp->sibling);
 | 
						list_del_init(&cgrp->sibling);
 | 
				
			||||||
	cgroup_unlock_hierarchy(cgrp->root);
 | 
						cgroup_unlock_hierarchy(cgrp->root);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						list_del_init(&cgrp->allcg_node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	d = dget(cgrp->dentry);
 | 
						d = dget(cgrp->dentry);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cgroup_d_remove_dir(d);
 | 
						cgroup_d_remove_dir(d);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue