[CRIU] [PATCH 2/3] page-read: Remove iov from get_pagemap

Pavel Emelyanov xemul at virtuozzo.com
Wed Nov 30 02:47:58 PST 2016


We have pr->pe with the same data available widely, no need
to copy this thing twice.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/cr-dedup.c        |  3 ++-
 criu/include/pagemap.h |  2 +-
 criu/mem.c             | 11 +++++------
 criu/pagemap.c         |  4 +---
 criu/shmem.c           |  8 ++++----
 5 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/criu/cr-dedup.c b/criu/cr-dedup.c
index 210e802..30a73e1 100644
--- a/criu/cr-dedup.c
+++ b/criu/cr-dedup.c
@@ -84,10 +84,11 @@ static int cr_dedup_one_pagemap(int id, int flags)
 		goto exit;
 
 	while (1) {
-		ret = pr.get_pagemap(&pr, &iov);
+		ret = pr.get_pagemap(&pr);
 		if (ret <= 0)
 			goto exit;
 
+		pagemap2iovec(pr.pe, &iov);
 		pr_debug("dedup iovec base=%p, len=%zu\n", iov.iov_base, iov.iov_len);
 		if (!pagemap_in_parent(pr.pe)) {
 			ret = dedup_one_iovec(prp, &iov);
diff --git a/criu/include/pagemap.h b/criu/include/pagemap.h
index 6f41ebc..d128103 100644
--- a/criu/include/pagemap.h
+++ b/criu/include/pagemap.h
@@ -46,7 +46,7 @@ struct page_read {
 	 * Gets next vaddr:len pair to work on. The zero pagemaps are skipped.
 	 * Pagemap entries should be returned in sorted order.
 	 */
-	int (*get_pagemap)(struct page_read *, struct iovec *iov);
+	int (*get_pagemap)(struct page_read *);
 	/* reads page from current pagemap */
 	int (*read_pages)(struct page_read *, unsigned long vaddr, int nr,
 			  void *, unsigned flags);
diff --git a/criu/mem.c b/criu/mem.c
index 2258605..4578ba9 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -736,22 +736,21 @@ static int restore_priv_vma_content(struct pstree_item *t)
 	 */
 	while (1) {
 		unsigned long off, i, nr_pages;
-		struct iovec iov;
 
-		ret = pr.get_pagemap(&pr, &iov);
+		ret = pr.get_pagemap(&pr);
 		if (ret <= 0)
 			break;
 
-		va = (unsigned long)iov.iov_base;
-		nr_pages = iov.iov_len / PAGE_SIZE;
+		va = (unsigned long)decode_pointer(pr.pe->vaddr);
+		nr_pages = pr.pe->nr_pages;
 
 		/*
 		 * 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);
+			pr_debug("Lazy restore skips %ld pages at %lx\n", nr_pages, va);
+			pr.skip_pages(&pr, nr_pages * PAGE_SIZE);
 			nr_lazy += nr_pages;
 			continue;
 		}
diff --git a/criu/pagemap.c b/criu/pagemap.c
index 5ba4c3f..afdfc6a 100644
--- a/criu/pagemap.c
+++ b/criu/pagemap.c
@@ -152,7 +152,7 @@ static int advance(struct page_read *pr, bool skip_zero)
 	return 1;
 }
 
-static int get_pagemap(struct page_read *pr, struct iovec *iov)
+static int get_pagemap(struct page_read *pr)
 {
 	if (!advance(pr, true))
 		return 0;
@@ -162,8 +162,6 @@ static int get_pagemap(struct page_read *pr, struct iovec *iov)
 		return -1;
 	}
 
-	pagemap2iovec(pr->pe, iov);
-
 	return 1;
 }
 
diff --git a/criu/shmem.c b/criu/shmem.c
index d0a284c..89e5f3e 100644
--- a/criu/shmem.c
+++ b/criu/shmem.c
@@ -19,6 +19,7 @@
 #include <compel/plugins/std/syscall-codes.h>
 #include "bitops.h"
 #include "log.h"
+#include "types.h"
 #include "page.h"
 #include "util.h"
 #include "protobuf.h"
@@ -470,14 +471,13 @@ static int restore_shmem_content(void *addr, struct shmem_info *si)
 	while (1) {
 		unsigned long vaddr;
 		unsigned nr_pages;
-		struct iovec iov;
 
-		ret = pr.get_pagemap(&pr, &iov);
+		ret = pr.get_pagemap(&pr);
 		if (ret <= 0)
 			break;
 
-		vaddr = (unsigned long)iov.iov_base;
-		nr_pages = iov.iov_len / PAGE_SIZE;
+		vaddr = (unsigned long)decode_pointer(pr.pe->vaddr);
+		nr_pages = pr.pe->nr_pages;
 
 		if (vaddr + nr_pages * PAGE_SIZE > si->size)
 			break;
-- 
2.5.0



More information about the CRIU mailing list