[CRIU] [PATCH 03/28] pid_ns: Make add_child_task() working with last_level_pid()

Andrei Vagin avagin at virtuozzo.com
Tue Jun 6 20:52:55 MSK 2017


Applied

On Mon, Jun 05, 2017 at 08:23:52PM +0300, Kirill Tkhai wrote:
> The original idea was to sort children and to keep child
> reapers at the beginning of the list. But there a mistake
> happened: we must look for last_level_pid() as it is
> an indicator of a child_reaper.
> 
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
>  criu/pstree.c |   10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/criu/pstree.c b/criu/pstree.c
> index dec77b81a..908e070d1 100644
> --- a/criu/pstree.c
> +++ b/criu/pstree.c
> @@ -256,15 +256,21 @@ struct pstree_item *__alloc_pstree_item(bool rst, int level)
>  	return item;
>  }
>  
> +/*
> + * Link child task to parent and try to keep parent's children sorted:
> + * child reapers at the beginning of list, the less pid->level is first.
> + * This gives basic protection against deadlock, when a tasks is waiting
> + * for pid_ns child reaper creation, while it's in the end of the list.
> + */
>  void add_child_task(struct pstree_item *child, struct pstree_item *parent)
>  {
>  	struct pstree_item *item;
>  
> -	if (vpid(child) != INIT_PID)
> +	if (last_level_pid(child->pid) != INIT_PID)
>  		list_add_tail(&child->sibling, &parent->children);
>  	else {
>  		list_for_each_entry(item, &parent->children, sibling)
> -			if (vpid(item) != INIT_PID ||
> +			if (last_level_pid(item->pid) != INIT_PID ||
>  			    item->pid->level >= child->pid->level)
>  				break;
>  		/* Add child before item */
> 


More information about the CRIU mailing list