[CRIU] [RFC PATCH 13/16] criu: lazy-pages: add nr_pages parameter to uffd_{copy, zero}
Mike Rapoport
rppt at linux.vnet.ibm.com
Tue Sep 27 06:42:14 PDT 2016
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
criu/uffd.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/criu/uffd.c b/criu/uffd.c
index 4b0fd44..83e36a1 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -498,21 +498,22 @@ static int get_pages(struct lazy_pages_info *lpi, unsigned long addr, int nr)
return nr;
}
-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;
if (opts.use_page_server)
rc = get_remote_pages(lpi->pid, address, 1, lpi->buf);
else
- rc = get_pages(lpi, address, 1);
+ rc = get_pages(lpi, address, nr_pages);
if (rc <= 0)
return 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;
@@ -526,25 +527,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);
@@ -556,16 +556,16 @@ 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)
{
int rc;
- rc = uffd_copy(lpi, address);
+ rc = uffd_copy(lpi, address, 1);
if (rc == 0)
- rc = uffd_zero(lpi, address);
+ rc = uffd_zero(lpi, address, 1);
return rc;
}
--
1.9.1
More information about the CRIU
mailing list