[CRIU] [PATCH 1/4] mem: Update stats for overflow page pipes

Pavel Emelianov xemul at virtuozzo.com
Thu May 23 11:58:04 MSK 2019


Since commit b5dff62e we skipped updating dump stats for pages
that overflowed the page-pipe and thus got flushed in "chunk"
mode.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 criu/mem.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/criu/mem.c b/criu/mem.c
index 8015a7e..72bf0cb 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -170,13 +170,14 @@ static int generate_iovs(struct pstree_item *item, struct vma_area *vma, struct
 	u64 *at = &map[PAGE_PFN(*off)];
 	unsigned long pfn, nr_to_scan;
 	unsigned long pages[3] = {};
+	int ret = 0;
 
 	nr_to_scan = (vma_area_len(vma) - *off) / PAGE_SIZE;
 
 	for (pfn = 0; pfn < nr_to_scan; pfn++) {
 		unsigned long vaddr;
 		unsigned int ppb_flags = 0;
-		int ret;
+		int st;
 
 		if (!should_dump_page(vma->e, at[pfn]))
 			continue;
@@ -195,19 +196,22 @@ static int generate_iovs(struct pstree_item *item, struct vma_area *vma, struct
 
 		if (has_parent && page_in_parent(at[pfn] & PME_SOFT_DIRTY)) {
 			ret = page_pipe_add_hole(pp, vaddr, PP_HOLE_PARENT);
-			pages[0]++;
+			st = 0;
 		} else {
 			ret = page_pipe_add_page(pp, vaddr, ppb_flags);
 			if (ppb_flags & PPB_LAZY && opts.lazy_pages)
-				pages[1]++;
+				st = 1;
 			else
-				pages[2]++;
+				st = 2;
 		}
 
 		if (ret) {
-			*off += pfn * PAGE_SIZE;
-			return ret;
+			/* Do not do pfn++, just bail out */
+			pr_debug("Pagemap full\n");
+			break;
 		}
+
+		pages[st]++;
 	}
 
 	*off += pfn * PAGE_SIZE;
@@ -219,7 +223,7 @@ static int generate_iovs(struct pstree_item *item, struct vma_area *vma, struct
 
 	pr_info("Pagemap generated: %lu pages (%lu lazy) %lu holes\n",
 		pages[2] + pages[1], pages[1], pages[0]);
-	return 0;
+	return ret;
 }
 
 static struct parasite_dump_pages_args *prep_dump_pages_args(struct parasite_ctl *ctl,
-- 
2.1.4



More information about the CRIU mailing list