[CRIU] [PATCH v4 11/12] criu: page-pipe: add ability to allocate IOVs

Pavel Emelyanov xemul at virtuozzo.com
Thu Jun 9 08:08:50 PDT 2016


On 06/06/2016 09:27 AM, Mike Rapoport wrote:
> When collection of dumpee pages is followed by any parasite operation, we
> cannot share iovs between parasite args area and page-pipe.
> 
> Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
> ---
>  criu/include/page-pipe.h |  1 +
>  criu/page-pipe.c         | 44 ++++++++++++++++++++++++++++----------------
>  2 files changed, 29 insertions(+), 16 deletions(-)
> 
> diff --git a/criu/include/page-pipe.h b/criu/include/page-pipe.h
> index 696dc9f..ca129fd 100644
> --- a/criu/include/page-pipe.h
> +++ b/criu/include/page-pipe.h
> @@ -95,6 +95,7 @@ struct page_pipe {
>  
>  	bool chunk_mode;	/* Restrict the maximum buffer size of pipes
>  				   and dump memory for a few iterations */
> +	bool own_iovs;		/* create_page_pipe allocated IOVs memory */
>  };
>  
>  extern struct page_pipe *create_page_pipe(unsigned int nr,
> diff --git a/criu/page-pipe.c b/criu/page-pipe.c
> index 5faf155..2b58aa9 100644
> --- a/criu/page-pipe.c
> +++ b/criu/page-pipe.c
> @@ -132,25 +132,35 @@ struct page_pipe *create_page_pipe(unsigned int nr_segs,
>  
>  	pr_debug("Create page pipe for %u segs\n", nr_segs);
>  
> -	pp = xmalloc(sizeof(*pp));
> -	if (pp) {
> -		pp->nr_pipes = 0;
> -		INIT_LIST_HEAD(&pp->bufs);
> -		INIT_LIST_HEAD(&pp->free_bufs);
> -		pp->nr_iovs = nr_segs;
> -		pp->iovs = iovs;
> -		pp->free_iov = 0;
> -
> -		pp->nr_holes = 0;
> -		pp->free_hole = 0;
> -		pp->holes = NULL;
> -
> -		pp->chunk_mode = chunk_mode;
> -
> -		if (page_pipe_grow(pp, 0))
> +	pp = xzalloc(sizeof(*pp));
> +	if (!pp)
> +		return NULL;
> +
> +	if (!iovs) {
> +		iovs = xmalloc(sizeof(*iovs) * nr_segs);

How will these bufs get filled with pages? The iovs are sent to parasite
so that it splice() data into them. If iovs sit in criu address space, then ... what?

> +		if (!iovs) {
> +			xfree(pp);
>  			return NULL;
> +		}
> +		pp->own_iovs = true;
>  	}
>  
> +	pp->nr_pipes = 0;
> +	INIT_LIST_HEAD(&pp->bufs);
> +	INIT_LIST_HEAD(&pp->free_bufs);
> +	pp->nr_iovs = nr_segs;
> +	pp->iovs = iovs;
> +	pp->free_iov = 0;
> +
> +	pp->nr_holes = 0;
> +	pp->free_hole = 0;
> +	pp->holes = NULL;
> +
> +	pp->chunk_mode = chunk_mode;
> +
> +	if (page_pipe_grow(pp, 0))
> +		return NULL;
> +
>  	return pp;
>  }
>  
> @@ -164,6 +174,8 @@ void destroy_page_pipe(struct page_pipe *pp)
>  	list_for_each_entry_safe(ppb, n, &pp->bufs, l)
>  		ppb_destroy(ppb);
>  
> +	if (pp->own_iovs)
> +		xfree(pp->iovs);
>  	xfree(pp);
>  }
>  
> 



More information about the CRIU mailing list