[CRIU] [PATCH 6/6] criu: mem: skip lazy pages during restore based on pagemap info

Mike Rapoport rppt at linux.vnet.ibm.com
Thu Sep 8 00:39:12 PDT 2016


Instead of checking whether the VMA containing a page can be lazy for each
page, skip the entire parts of pagemap that have PE_LAZY flag set.

Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
 criu/mem.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/criu/mem.c b/criu/mem.c
index 1c01a09..597bf29 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -718,6 +718,17 @@ static int restore_priv_vma_content(struct pstree_item *t)
 		va = (unsigned long)iov.iov_base;
 		nr_pages = iov.iov_len / PAGE_SIZE;
 
+		/*
+		 * This means that userfaultfd is used to load the pages
+		 * on demand.
+		 */
+		if (opts.lazy_pages && pagemap_lazy(pr.pe)) {
+			pr_debug("Lazy restore skips %ld pages at %p\n", nr_pages, iov.iov_base);
+			pr.skip_pages(&pr, iov.iov_len);
+			nr_lazy += nr_pages;
+			continue;
+		}
+
 		for (i = 0; i < nr_pages; i++) {
 			unsigned char buf[PAGE_SIZE];
 			void *p;
@@ -749,17 +760,6 @@ static int restore_priv_vma_content(struct pstree_item *t)
 			p = decode_pointer((off) * PAGE_SIZE +
 					vma->premmaped_addr);
 
-			/*
-			 * This means that userfaultfd is used to load the pages
-			 * on demand.
-			 */
-			if (opts.lazy_pages && vma_entry_can_be_lazy(vma->e)) {
-				pr_debug("Lazy restore skips %#016"PRIx64"\n", vma->e->start);
-				pr.skip_pages(&pr, PAGE_SIZE);
-				nr_lazy++;
-				continue;
-			}
-
 			set_bit(off, vma->page_bitmap);
 			if (vma->ppage_bitmap) { /* inherited vma */
 				clear_bit(off, vma->ppage_bitmap);
-- 
1.9.1



More information about the CRIU mailing list