[CRIU] [PATCH 1/5] uffd: Unify page handling in normal and remaining modes

Mike Rapoport mike.rapoport at gmail.com
Mon Nov 21 04:45:39 PST 2016


On Mon, Nov 21, 2016 at 02:26:12PM +0300, Pavel Emelyanov wrote:
> This run away from previous set :) Two routines are now
> identical, only page-read flags differ.
> 
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>

Except some nitpeek below

Acked-by: Mike Rapoport <rppt at linux.vnet.ibm.com>

> ---
>  criu/uffd.c | 25 ++++---------------------
>  1 file changed, 4 insertions(+), 21 deletions(-)
> 
> diff --git a/criu/uffd.c b/criu/uffd.c
> index cd370aa..f3b4f4a 100644
> --- a/criu/uffd.c
> +++ b/criu/uffd.c
> @@ -634,7 +634,7 @@ static int uffd_seek_or_zero_pages(struct lazy_pages_info *lpi, __u64 address,
>  	return 1;
>  }
>  
> -static int uffd_handle_pages(struct lazy_pages_info *lpi, __u64 address, int nr)
> +static int handle_page_fault(struct lazy_pages_info *lpi, __u64 address, int nr, unsigned flags)
>  {
>  	int ret;
>  
> @@ -642,7 +642,7 @@ static int uffd_handle_pages(struct lazy_pages_info *lpi, __u64 address, int nr)
>  	if (ret <= 0)
>  		return ret;
>  
> -	ret = lpi->pr.read_pages(&lpi->pr, address, nr, lpi->buf, 0);
> +	ret = lpi->pr.read_pages(&lpi->pr, address, nr, lpi->buf, flags);
>  	if (ret <= 0) {
>  		pr_err("%d: failed reading pages at %llx\n", lpi->pid, address);
>  		return ret;
> @@ -663,7 +663,7 @@ static int handle_remaining_pages(struct lazy_pages_info *lpi)
>  	list_for_each_entry(lazy_iov, &lpi->iovs, l) {
>  		nr_pages = lazy_iov->len / PAGE_SIZE;
>  
> -		err = uffd_handle_pages(lpi, lazy_iov->base, nr_pages);
> +		err = handle_page_fault(lpi, lazy_iov->base, nr_pages, 0);

At this point we do not have a page fault, so maybe it'd be better to leave
uffd_handle_pages and drop handle_page_fault.

>  		if (err < 0) {
>  			pr_err("Error during UFFD copy\n");
>  			return -1;
> @@ -673,23 +673,6 @@ static int handle_remaining_pages(struct lazy_pages_info *lpi)
>  	return 0;
>  }
>  
> -static int handle_page_fault(struct lazy_pages_info *lpi, __u64 address, int nr)
> -{
> -	int ret;
> -
> -	ret = uffd_seek_or_zero_pages(lpi, address, nr);
> -	if (ret <= 0)
> -		return ret;
> -
> -	ret = lpi->pr.read_pages(&lpi->pr, address, nr, lpi->buf, PR_ASYNC | PR_ASAP);
> -	if (ret <= 0) {
> -		pr_err("%d: failed reading pages at %llx\n", lpi->pid, address);
> -		return ret;
> -	}
> -
> -	return 0;
> -}
> -
>  static int handle_user_fault(struct lazy_pages_fd *lpfd)
>  {
>  	struct lazy_pages_info *lpi;
> @@ -726,7 +709,7 @@ static int handle_user_fault(struct lazy_pages_fd *lpfd)
>  	flags = msg.arg.pagefault.flags;
>  	pr_debug("msg.arg.pagefault.flags 0x%llx\n", flags);
>  
> -	ret = handle_page_fault(lpi, address, 1);
> +	ret = handle_page_fault(lpi, address, 1, PR_ASYNC | PR_ASAP);
>  	if (ret < 0) {
>  		pr_err("Error during regular page copy\n");
>  		return -1;
> -- 
> 2.5.0
> 


More information about the CRIU mailing list