[CRIU] [PATCH 2/7] page-read: Fix maybe_read_page to accept nr
Mike Rapoport
mike.rapoport at gmail.com
Wed Nov 16 02:40:09 PST 2016
On Wed, Nov 16, 2016 at 11:38 AM, Pavel Emelyanov <xemul at virtuozzo.com> wrote:
> Most of the rest code uses int nr, so ...
I liked my indentation more :-)
> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
Acked-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
> ---
> criu/include/pagemap.h | 2 +-
> criu/pagemap.c | 15 +++++++--------
> 2 files changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/criu/include/pagemap.h b/criu/include/pagemap.h
> index e4a4ecd..98ad7ae 100644
> --- a/criu/include/pagemap.h
> +++ b/criu/include/pagemap.h
> @@ -59,7 +59,7 @@ struct page_read {
> int (*sync)(struct page_read *pr);
>
> int (*maybe_read_page)(struct page_read *pr, unsigned long vaddr,
> - unsigned long len, void *buf, unsigned flags);
> + int nr, void *buf, unsigned flags);
>
> /* Private data of reader */
> struct cr_img *pmi;
> diff --git a/criu/pagemap.c b/criu/pagemap.c
> index f19c0ed..e05a468 100644
> --- a/criu/pagemap.c
> +++ b/criu/pagemap.c
> @@ -379,9 +379,10 @@ static int enqueue_async_page(struct page_read *pr, unsigned long vaddr,
> }
>
> static int maybe_read_page_local(struct page_read *pr, unsigned long vaddr,
> - unsigned long len, void *buf, unsigned flags)
> + int nr, void *buf, unsigned flags)
> {
> int ret;
> + unsigned long len = nr * PAGE_SIZE;
>
> if (flags & PR_ASYNC)
> ret = enqueue_async_page(pr, vaddr, len, buf);
> @@ -394,7 +395,7 @@ static int maybe_read_page_local(struct page_read *pr, unsigned long vaddr,
> }
>
> static int maybe_read_page_remote(struct page_read *pr, unsigned long vaddr,
> - unsigned long len, void *buf, unsigned flags)
> + int nr, void *buf, unsigned flags)
> {
> int ret;
>
> @@ -403,9 +404,9 @@ static int maybe_read_page_remote(struct page_read *pr, unsigned long vaddr,
> * Note, that for async remote page_read, the actual
> * transfer happens in the lazy-pages daemon
> */
> - ret = request_remote_pages(pr->pid, vaddr, len / PAGE_SIZE);
> + ret = request_remote_pages(pr->pid, vaddr, nr);
> else
> - ret = get_remote_pages(pr->pid, vaddr, len / PAGE_SIZE, buf);
> + ret = get_remote_pages(pr->pid, vaddr, nr, buf);
>
> return ret;
> }
> @@ -413,8 +414,6 @@ static int maybe_read_page_remote(struct page_read *pr, unsigned long vaddr,
> static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, int nr,
> void *buf, unsigned flags)
> {
> - unsigned long len = nr * PAGE_SIZE;
> -
> pr_info("pr%u Read %lx %u pages\n", pr->id, vaddr, nr);
> pagemap_bound_check(pr->pe, vaddr, nr);
>
> @@ -425,11 +424,11 @@ static int read_pagemap_page(struct page_read *pr, unsigned long vaddr, int nr,
> /* zero mappings should be skipped by get_pagemap */
> BUG();
> } else {
> - if (pr->maybe_read_page(pr, vaddr, len, buf, flags) < 0)
> + if (pr->maybe_read_page(pr, vaddr, nr, buf, flags) < 0)
> return -1;
> }
>
> - pr->cvaddr += len;
> + pr->cvaddr += nr * PAGE_SIZE;
>
> return 1;
> }
> --
> 2.5.0
>
--
Sincerely yours,
Mike.
More information about the CRIU
mailing list