[CRIU] [PATCH v2 10/11] criu: page-pipe: add ability to allocate IOVs

Mike Rapoport rppt at linux.vnet.ibm.com
Tue May 31 06:35:00 PDT 2016


When collection of dumpee pages is followed by any parasite operation, we
cannot share iovs between parasite args area and page-pipe.

Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
 criu/include/page-pipe.h |  1 +
 criu/page-pipe.c         | 40 ++++++++++++++++++++++++++--------------
 2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/criu/include/page-pipe.h b/criu/include/page-pipe.h
index a18db62..17649a2 100644
--- a/criu/include/page-pipe.h
+++ b/criu/include/page-pipe.h
@@ -95,6 +95,7 @@ struct page_pipe {
 
 	bool chunk_mode;	/* Restrict the maximum buffer size of pipes
 				   and dump memory for a few iterations */
+	bool own_iovs;		/* create_page_pipe allocated IOVs memory */
 };
 
 extern struct page_pipe *create_page_pipe(unsigned int nr,
diff --git a/criu/page-pipe.c b/criu/page-pipe.c
index 2078365..cd8cb8d 100644
--- a/criu/page-pipe.c
+++ b/criu/page-pipe.c
@@ -132,24 +132,34 @@ struct page_pipe *create_page_pipe(unsigned int nr_segs,
 	pr_debug("Create page pipe for %u segs\n", nr_segs);
 
 	pp = xmalloc(sizeof(*pp));
-	if (pp) {
-		pp->nr_pipes = 0;
-		INIT_LIST_HEAD(&pp->bufs);
-		INIT_LIST_HEAD(&pp->free_bufs);
-		pp->nr_iovs = nr_segs;
-		pp->iovs = iovs;
-		pp->free_iov = 0;
-
-		pp->nr_holes = 0;
-		pp->free_hole = 0;
-		pp->holes = NULL;
-
-		pp->chunk_mode = chunk_mode;
+	if (!pp)
+		return NULL;
 
-		if (page_pipe_grow(pp, 0))
+	if (!iovs) {
+		iovs = xmalloc(sizeof(*iovs) * nr_segs);
+		if (!iovs) {
+			xfree(pp);
 			return NULL;
+		}
+		pp->own_iovs = true;
 	}
 
+	pp->nr_pipes = 0;
+	INIT_LIST_HEAD(&pp->bufs);
+	INIT_LIST_HEAD(&pp->free_bufs);
+	pp->nr_iovs = nr_segs;
+	pp->iovs = iovs;
+	pp->free_iov = 0;
+
+	pp->nr_holes = 0;
+	pp->free_hole = 0;
+	pp->holes = NULL;
+
+	pp->chunk_mode = chunk_mode;
+
+	if (page_pipe_grow(pp, 0))
+		return NULL;
+
 	return pp;
 }
 
@@ -163,6 +173,8 @@ void destroy_page_pipe(struct page_pipe *pp)
 	list_for_each_entry_safe(ppb, n, &pp->bufs, l)
 		ppb_destroy(ppb);
 
+	if (pp->own_iovs)
+		xfree(pp->iovs);
 	xfree(pp);
 }
 
-- 
1.9.1



More information about the CRIU mailing list