[CRIU] [RFC 2/3] mem: Switch to use virtual address in generate_iovs

Cyrill Gorcunov gorcunov at openvz.org
Thu Feb 13 12:41:12 PST 2014


In pagemap-cache engine we're using virtuall addresses
to fetch PMEs, thus change the meaning of @off variable
to carry virtual address instead.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 mem.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/mem.c b/mem.c
index 65a1b7a7d337..2c2717d290d6 100644
--- a/mem.c
+++ b/mem.c
@@ -110,25 +110,25 @@ static int generate_iovs(struct vma_area *vma, int pagemap,
 {
 	unsigned long pfn, nr_to_scan;
 	unsigned long pages[2] = {};
+	unsigned long vaddr = *off;
 	u64 from, len;
 
-	nr_to_scan = (vma_area_len(vma) - *off) / PAGE_SIZE;
-	from = (vma->e->start + *off) / PAGE_SIZE * sizeof(*map);
+	nr_to_scan = (vma->e->end - vaddr) / PAGE_SIZE;
+	from = vaddr / PAGE_SIZE * sizeof(*map);
 	len = nr_to_scan * sizeof(*map);
 	if (pread(pagemap, map, len, from) != len) {
 		pr_perror("Can't read pagemap file");
 		return -1;
 	}
 
-	for (pfn = 0; pfn < nr_to_scan; pfn++) {
-		unsigned long vaddr;
+	for ( ; vaddr < vma->e->end; vaddr += PAGE_SIZE) {
 		int ret;
 
+		pfn = (vaddr - vma->e->start) / PAGE_SIZE;
+
 		if (!should_dump_page(vma->e, map[pfn]))
 			continue;
 
-		vaddr = vma->e->start + *off + pfn * PAGE_SIZE;
-
 		/*
 		 * If we're doing incremental dump (parent images
 		 * specified) and page is not soft-dirty -- we dump
@@ -145,12 +145,12 @@ static int generate_iovs(struct vma_area *vma, int pagemap,
 		}
 
 		if (ret) {
-			*off += (pfn - 1) * PAGE_SIZE;
+			*off = vaddr - PAGE_SIZE;
 			return ret;
 		}
 	}
 
-	*off += pfn * PAGE_SIZE;
+	*off = vaddr;
 
 	cnt_add(CNT_PAGES_SCANNED, nr_to_scan);
 	cnt_add(CNT_PAGES_SKIPPED_PARENT, pages[0]);
@@ -283,7 +283,7 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl,
 	 */
 	args->off = 0;
 	list_for_each_entry(vma_area, &vma_area_list->h, list) {
-		u64 off = 0;
+		u64 off = vma_area->e->start;
 
 		if (!privately_dump_vma(vma_area))
 			continue;
-- 
1.8.3.1



More information about the CRIU mailing list