[CRIU] [PATCH 11/12] page-xfer: Move lazy bool on xfer

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


Same thing for the boolean value saying whether or not to send
lazy pagemaps alone or follow them with the respective pages.
This value is non-true in the single place, so let's simplify
the API and keep this bool on xfer object.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/cr-dump.c           |  2 +-
 criu/include/page-xfer.h |  3 ++-
 criu/mem.c               | 10 ++++++----
 criu/page-xfer.c         |  6 +++---
 criu/shmem.c             |  2 +-
 5 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index 2c0145a..c1dc58a 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -1571,7 +1571,7 @@ static int cr_pre_dump_finish(int ret)
 			goto err;
 
 		mem_pp = dmpi(item)->mem_pp;
-		ret = page_xfer_dump_pages(&xfer, mem_pp, true);
+		ret = page_xfer_dump_pages(&xfer, mem_pp);
 
 		xfer.close(&xfer);
 
diff --git a/criu/include/page-xfer.h b/criu/include/page-xfer.h
index 38ea59c..ffb6b08 100644
--- a/criu/include/page-xfer.h
+++ b/criu/include/page-xfer.h
@@ -27,6 +27,7 @@ struct page_xfer {
 	 * relative to some address. Used, e.g. by shmem.
 	 */
 	unsigned long offset;
+	bool transfer_lazy;
 
 	/* private data for every page-xfer engine */
 	union {
@@ -46,7 +47,7 @@ struct page_xfer {
 
 extern int open_page_xfer(struct page_xfer *xfer, int fd_type, long id);
 struct page_pipe;
-extern int page_xfer_dump_pages(struct page_xfer *, struct page_pipe *, bool dump_lazy);
+extern int page_xfer_dump_pages(struct page_xfer *, struct page_pipe *);
 extern int connect_to_page_server_to_send(void);
 extern int connect_to_page_server_to_recv(int epfd);
 extern int disconnect_from_page_server(void);
diff --git a/criu/mem.c b/criu/mem.c
index 2eaf89e..e454b36 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -273,7 +273,7 @@ static int drain_pages(struct page_pipe *pp, struct parasite_ctl *ctl,
 	return 0;
 }
 
-static int xfer_pages(struct page_pipe *pp, struct page_xfer *xfer, bool lazy)
+static int xfer_pages(struct page_pipe *pp, struct page_xfer *xfer)
 {
 	int ret;
 
@@ -282,7 +282,7 @@ static int xfer_pages(struct page_pipe *pp, struct page_xfer *xfer, bool lazy)
 	 *           pre-dump action (see pre_dump_one_task)
 	 */
 	timing_start(TIME_MEMWRITE);
-	ret = page_xfer_dump_pages(xfer, pp, !lazy);
+	ret = page_xfer_dump_pages(xfer, pp);
 	timing_stop(TIME_MEMWRITE);
 
 	return ret;
@@ -347,6 +347,8 @@ static int __parasite_dump_pages_seized(struct pstree_item *item,
 		ret = open_page_xfer(&xfer, CR_FD_PAGEMAP, vpid(item));
 		if (ret < 0)
 			goto out_pp;
+
+		xfer.transfer_lazy = !mdc->lazy;
 	} else {
 		ret = check_parent_page_xfer(CR_FD_PAGEMAP, vpid(item));
 		if (ret < 0)
@@ -388,7 +390,7 @@ again:
 
 				ret = drain_pages(pp, ctl, args);
 				if (!ret)
-					ret = xfer_pages(pp, &xfer, mdc->lazy /* false actually */);
+					ret = xfer_pages(pp, &xfer);
 				if (!ret) {
 					page_pipe_reinit(pp);
 					goto again;
@@ -404,7 +406,7 @@ again:
 		       sizeof(struct iovec) * pp->nr_iovs);
 	ret = drain_pages(pp, ctl, args);
 	if (!ret && !mdc->pre_dump)
-		ret = xfer_pages(pp, &xfer, mdc->lazy);
+		ret = xfer_pages(pp, &xfer);
 	if (ret)
 		goto out_xfer;
 
diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index 91398e7..10da75f 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -350,6 +350,7 @@ out:
 int open_page_xfer(struct page_xfer *xfer, int fd_type, long id)
 {
 	xfer->offset = 0;
+	xfer->transfer_lazy = true;
 
 	if (opts.use_page_server)
 		return open_page_server_xfer(xfer, fd_type, id);
@@ -404,8 +405,7 @@ static int dump_holes(struct page_xfer *xfer, struct page_pipe *pp,
 	return 0;
 }
 
-int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp,
-		bool dump_lazy)
+int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp)
 {
 	struct page_pipe_buf *ppb;
 	unsigned int cur_hole = 0;
@@ -432,7 +432,7 @@ int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp,
 					(unsigned int)(iov.iov_len / PAGE_SIZE));
 
 			if (ppb->flags & PPB_LAZY) {
-				if (!dump_lazy) {
+				if (!xfer->transfer_lazy) {
 					if (xfer->write_pagemap(xfer, &iov, PE_LAZY))
 						return -1;
 					continue;
diff --git a/criu/shmem.c b/criu/shmem.c
index 27778f9..2de8cb4 100644
--- a/criu/shmem.c
+++ b/criu/shmem.c
@@ -636,7 +636,7 @@ static int dump_pages(struct page_pipe *pp, struct page_xfer *xfer)
 			return -1;
 		}
 
-	return page_xfer_dump_pages(xfer, pp, true);
+	return page_xfer_dump_pages(xfer, pp);
 }
 
 static int next_data_segment(int fd, unsigned long pfn,
-- 
2.1.4



More information about the CRIU mailing list