[CRIU] [PATCH 04/12] pagemap: Remove seek_pagemap_page

Pavel Emelyanov xemul at virtuozzo.com
Wed Jun 28 16:46:48 MSK 2017


The page_read.seek_pagemap already tunes the pages offset,
so the separate call for skip_pagemap_pages in the routine
in question is always no-op.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/pagemap.c | 18 +++---------------
 criu/uffd.c    |  4 +---
 2 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/criu/pagemap.c b/criu/pagemap.c
index 3b4c144..f7e1173 100644
--- a/criu/pagemap.c
+++ b/criu/pagemap.c
@@ -75,8 +75,6 @@ static int punch_hole(struct page_read *pr, unsigned long off,
 	return 0;
 }
 
-static int seek_pagemap_page(struct page_read *pr, unsigned long vaddr);
-
 int dedup_one_iovec(struct page_read *pr, unsigned long off, unsigned long len)
 {
 	unsigned long iov_end;
@@ -87,7 +85,7 @@ int dedup_one_iovec(struct page_read *pr, unsigned long off, unsigned long len)
 		unsigned long piov_end;
 		struct page_read * prp;
 
-		ret = seek_pagemap_page(pr, off);
+		ret = pr->seek_pagemap(pr, off);
 		if (ret == 0) {
 			pr_warn("Missing %lx in parent pagemap\n", off);
 			if (off < pr->cvaddr && pr->cvaddr < iov_end)
@@ -164,7 +162,7 @@ static int seek_pagemap(struct page_read *pr, unsigned long vaddr)
 			break;
 
 		if (vaddr >= start && vaddr < end) {
-			skip_pagemap_pages(pr, start > pr->cvaddr ? start - pr->cvaddr : 0);
+			skip_pagemap_pages(pr, vaddr > pr->cvaddr ? vaddr - pr->cvaddr : 0);
 			return 1;
 		}
 
@@ -177,16 +175,6 @@ adv:
 	return 0;
 }
 
-static int seek_pagemap_page(struct page_read *pr, unsigned long vaddr)
-{
-	if (seek_pagemap(pr, vaddr)) {
-		skip_pagemap_pages(pr, vaddr > pr->cvaddr ? vaddr - pr->cvaddr : 0);
-		return 1;
-	}
-
-	return 0;
-}
-
 static inline void pagemap_bound_check(PagemapEntry *pe, unsigned long vaddr, int nr)
 {
 	if (vaddr < pe->vaddr || (vaddr - pe->vaddr) / PAGE_SIZE + nr > pe->nr_pages) {
@@ -219,7 +207,7 @@ static int read_parent_page(struct page_read *pr, unsigned long vaddr,
 		int p_nr;
 
 		pr_debug("\tpr%d-%u Read from parent\n", pr->pid, pr->id);
-		ret = seek_pagemap_page(ppr, vaddr);
+		ret = ppr->seek_pagemap(ppr, vaddr);
 		if (ret <= 0) {
 			pr_err("Missing %lx in parent pagemap\n", vaddr);
 			return -1;
diff --git a/criu/uffd.c b/criu/uffd.c
index d631f4b..76c08c3 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -787,11 +787,9 @@ static int uffd_seek_pages(struct lazy_pages_info *lpi, __u64 address, int nr)
 	ret = lpi->pr.seek_pagemap(&lpi->pr, address);
 	if (!ret) {
 		lp_err(lpi, "no pagemap covers %llx\n", address);
-		return ret;
+		return -1;
 	}
 
-	lpi->pr.skip_pages(&lpi->pr, address - lpi->pr.pe->vaddr);
-
 	return 0;
 }
 
-- 
2.1.4



More information about the CRIU mailing list