[CRIU] [PATCH] cg: Don't walk cgroup tree when it's not required

Andrew Vagin avagin at parallels.com
Wed Jul 16 01:00:49 PDT 2014


On Tue, Jul 15, 2014 at 05:57:55PM +0400, Pavel Emelyanov wrote:
> We have two bugs actually.
> 
> First, the check for 'item == root_item' in dump_task_cgroup fires
> twice: first when we rite inventory (item == NULL as argument and
> root_item == NULL because we haven't yet collected tasks) and the
> 2nd time when we dump the root task itself.
> 
> The 2nd issue sits in dump_cgroups() -- if root_cgset == criu_cgset
> we don't write cgroups information at all (checking that we don't
> have them with list_is_singular() inside that if). That said, we
> don't need to read the cgroups tree if we're not going to dump it.
> 
> This patch fixes both.

Acked-by: Andrew Vagin <avagin at parallels.com>

> 
> Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
> 
> ---
> 
> diff --git a/cgroup.c b/cgroup.c
> index 400ffe8..0a1ef42 100644
> --- a/cgroup.c
> +++ b/cgroup.c
> @@ -439,9 +439,6 @@ int dump_task_cgroup(struct pstree_item *item, u32 *cg_id)
>  	if (parse_task_cgroup(pid, &ctls, &n_ctls))
>  		return -1;
>  
> -	if (item == root_item && collect_cgroups(&ctls) < 0)
> -		return -1;
> -
>  	cs = get_cg_set(&ctls, n_ctls);
>  	if (!cs)
>  		return -1;
> @@ -454,6 +451,13 @@ int dump_task_cgroup(struct pstree_item *item, u32 *cg_id)
>  		BUG_ON(root_cgset);
>  		root_cgset = cs;
>  		pr_info("Set %d is root one\n", cs->id);
> +
> +		/*
> +		 * The on-stack ctls is moved into cs inside
> +		 * the get_cg_set routine.
> +		 */
> +		if (cs != criu_cgset && collect_cgroups(&cs->ctls))
> +			return -1;
>  	}
>  
>  	*cg_id = cs->id;
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list