[CRIU] [PATCH 5/7] uffd: Helper to complete the #PF

Mike Rapoport mike.rapoport at gmail.com
Wed Nov 16 02:56:25 PST 2016


On Wed, Nov 16, 2016 at 11:39 AM, Pavel Emelyanov <xemul at virtuozzo.com> wrote:
> The _copy and _update_lazy_iovecs are both called by hands
> once the data is ready.
>
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
> ---

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

>  criu/uffd.c | 32 +++++++++++++++++---------------
>  1 file changed, 17 insertions(+), 15 deletions(-)
>
> diff --git a/criu/uffd.c b/criu/uffd.c
> index 46ac9f2..93cdee7 100644
> --- a/criu/uffd.c
> +++ b/criu/uffd.c
> @@ -82,6 +82,7 @@ struct lazy_pages_info {
>         struct list_head l;
>
>         void *buf;
> +       bool remaining;
>  };
>
>  static LIST_HEAD(lpis);
> @@ -575,6 +576,17 @@ static int uffd_copy(struct lazy_pages_info *lpi, __u64 address, int nr_pages)
>         return 0;
>  }
>
> +static int complete_page_fault(struct lazy_pages_info *lpi, unsigned long vaddr, int nr)
> +{
> +       if (uffd_copy(lpi, vaddr, nr))
> +               return -1;
> +
> +       if (lpi->remaining)
> +               return 0;
> +
> +       return update_lazy_iovecs(lpi, vaddr, nr * PAGE_SIZE);
> +}
> +
>  static int uffd_zero(struct lazy_pages_info *lpi, __u64 address, int nr_pages)
>  {
>         struct uffdio_zeropage uffdio_zeropage;
> @@ -643,7 +655,7 @@ static int uffd_handle_pages(struct lazy_pages_info *lpi, __u64 address, int nr)
>                 return ret;
>         }
>
> -       return uffd_copy(lpi, address, nr);
> +       return complete_page_fault(lpi, address, nr);
>  }
>
>  static int handle_remaining_pages(struct lazy_pages_info *lpi)
> @@ -651,6 +663,8 @@ static int handle_remaining_pages(struct lazy_pages_info *lpi)
>         struct lazy_iovec *lazy_iov;
>         int nr_pages, err;
>
> +       lpi->remaining = true;
> +
>         lpi->pr.reset(&lpi->pr);
>
>         list_for_each_entry(lazy_iov, &lpi->iovs, l) {
> @@ -689,13 +703,7 @@ static int page_fault_local(struct lazy_pages_info *lpi, __u64 address, int nr)
>         if (page_fault_common(lpi, address, nr, PR_ASYNC | PR_ASAP))
>                 return -1;
>
> -       if (uffd_copy(lpi, address, nr))
> -               return -1;
> -
> -       if (update_lazy_iovecs(lpi, address, PAGE_SIZE * nr))
> -               return -1;
> -
> -       return 0;
> +       return complete_page_fault(lpi, address, nr);
>  }
>
>  static int page_fault_remote(struct lazy_pages_info *lpi, __u64 address, int nr)
> @@ -963,13 +971,7 @@ static int page_server_event(struct lazy_pages_fd *lpfd)
>                 if (receive_remote_pages(nr_pages * PAGE_SIZE, lpi->buf))
>                         return -1;
>
> -               if (uffd_copy(lpi, addr, nr_pages))
> -                       return -1;
> -
> -               if (update_lazy_iovecs(lpi, addr, PAGE_SIZE * nr_pages))
> -                       return -1;
> -
> -               return 0;
> +               return complete_page_fault(lpi, addr, nr_pages);
>         }
>  }
>
> --
> 2.5.0
>



-- 
Sincerely yours,
Mike.


More information about the CRIU mailing list