[CRIU] [PATCH 1/5] uffd: Unify page handling in normal and remaining modes (v2)
Pavel Emelyanov
xemul at virtuozzo.com
Tue Nov 22 04:10:09 PST 2016
This run away from previous set :) Two routines are now
identical, only page-read flags differ.
v2: Keep the uffd_hanle_pages() name
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
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..94d0863 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 uffd_handle_pages(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 = uffd_handle_pages(lpi, lazy_iov->base, nr_pages, 0);
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 = uffd_handle_pages(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