[CRIU] [PATCH v3 08/19] criu: lazy-pages: add nr_pages parameter to uffd_{copy, zero}
Mike Rapoport
rppt at linux.vnet.ibm.com
Tue Nov 15 08:57:17 PST 2016
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
criu/uffd.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/criu/uffd.c b/criu/uffd.c
index 7ffc6de..ac08995 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -512,14 +512,15 @@ out:
return -1;
}
-static int uffd_copy(struct lazy_pages_info *lpi, __u64 address)
+static int uffd_copy(struct lazy_pages_info *lpi, __u64 address, int nr_pages)
{
struct uffdio_copy uffdio_copy;
+ unsigned long len = nr_pages * page_size();
int rc;
uffdio_copy.dst = address;
uffdio_copy.src = (unsigned long)lpi->buf;
- uffdio_copy.len = page_size();
+ uffdio_copy.len = len;
uffdio_copy.mode = 0;
uffdio_copy.copy = 0;
@@ -533,25 +534,24 @@ static int uffd_copy(struct lazy_pages_info *lpi, __u64 address)
pr_err("UFFDIO_COPY error %Ld\n", uffdio_copy.copy);
return -1;
}
- } else if (uffdio_copy.copy != page_size()) {
+ } else if (uffdio_copy.copy != len) {
pr_err("UFFDIO_COPY unexpected size %Ld\n", uffdio_copy.copy);
return -1;
}
- lpi->copied_pages++;
+ lpi->copied_pages += nr_pages;
return uffdio_copy.copy;
-
}
-static int uffd_zero(struct lazy_pages_info *lpi, __u64 address)
+static int uffd_zero(struct lazy_pages_info *lpi, __u64 address, int nr_pages)
{
struct uffdio_zeropage uffdio_zeropage;
- unsigned long ps = page_size();
+ unsigned long len = page_size() * nr_pages;
int rc;
uffdio_zeropage.range.start = address;
- uffdio_zeropage.range.len = ps;
+ uffdio_zeropage.range.len = len;
uffdio_zeropage.mode = 0;
pr_debug("uffdio_zeropage.range.start 0x%llx\n", uffdio_zeropage.range.start);
@@ -563,7 +563,7 @@ static int uffd_zero(struct lazy_pages_info *lpi, __u64 address)
return -1;
}
- return ps;
+ return len;
}
static int uffd_handle_page(struct lazy_pages_info *lpi, __u64 address)
@@ -583,7 +583,7 @@ static int uffd_handle_page(struct lazy_pages_info *lpi, __u64 address)
* seek_page return value here
*/
if (ret == 0 || pagemap_zero(lpi->pr.pe))
- return uffd_zero(lpi, address);
+ return uffd_zero(lpi, address, 1);
if (opts.use_page_server)
ret = get_remote_pages(lpi->pid, address, 1, lpi->buf);
@@ -595,7 +595,7 @@ static int uffd_handle_page(struct lazy_pages_info *lpi, __u64 address)
return ret;
}
- return uffd_copy(lpi, address);
+ return uffd_copy(lpi, address, 1);
}
static int handle_remaining_pages(struct lazy_pages_info *lpi)
--
1.9.1
More information about the CRIU
mailing list