[1/3] mem: Update stats for overflow page pipes

Submitted by Pavel Emelianov on May 16, 2019, 3:22 p.m.

Details

Message ID 9eb0b2c0-96bb-a83c-b11d-155f90e02915@virtuozzo.com
State New
Series "stats: Fix, tune and check badly accounted dump stats"
Headers show

Commit Message

Pavel Emelianov May 16, 2019, 3:22 p.m.
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@virtuozzo.com>
---
 criu/mem.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

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,