[CRIU] [PATCH v3 07/12] mem: generalize page_in_parent function and make it extern

Eugene Batalov eabatalov89 at gmail.com
Sun Aug 7 06:11:11 PDT 2016


From: Fyodor Bocharov <bocharovfedor at gmail.com>

If we want to dedup anon shared memory we need to call page_in_parent.
So we need to make it extern.
Also in case of anon shared mem we have only 1 bit per page so we have to
change page_in_parent signature.

Signed-off-by: Fyodor Bocharov <fbocharov at yandex.ru>
Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
---
 criu/include/mem.h | 3 +++
 criu/mem.c         | 7 ++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/criu/include/mem.h b/criu/include/mem.h
index cbb4aac..c4b1ffc 100644
--- a/criu/include/mem.h
+++ b/criu/include/mem.h
@@ -1,12 +1,15 @@
 #ifndef __CR_MEM_H__
 #define __CR_MEM_H__
 
+#include <stdbool.h>
+
 struct parasite_ctl;
 struct vm_area_list;
 struct page_pipe;
 struct pstree_item;
 
 extern int task_reset_dirty_track(int pid);
+extern bool page_in_parent(bool dirty);
 extern int prepare_mm_pid(struct pstree_item *i);
 extern int do_task_reset_dirty_track(int pid);
 extern unsigned int dump_pages_args_size(struct vm_area_list *vmas);
diff --git a/criu/mem.c b/criu/mem.c
index 05c7772..a63b5f6 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -118,14 +118,14 @@ static inline bool page_is_zero(u64 pme)
 	return (pme & PME_PFRAME_MASK) == kdat.zero_page_pfn;
 }
 
-static inline bool page_in_parent(u64 pme)
+bool page_in_parent(bool dirty)
 {
 	/*
 	 * If we do memory tracking, but w/o parent images,
 	 * then we have to dump all memory
 	 */
 
-	return opts.track_mem && opts.img_parent && !(pme & PME_SOFT_DIRTY);
+	return opts.track_mem && opts.img_parent && !dirty;
 }
 
 /*
@@ -168,7 +168,8 @@ static int generate_iovs(struct vma_area *vma, struct page_pipe *pp, u64 *map, u
 		if (page_is_zero(at[pfn])) {
 			ret = page_pipe_add_hole(pp, vaddr, PP_HOLE_ZERO);
 			pages[0]++;
-		} else if (has_parent && page_in_parent(at[pfn])) {
+		} else if (has_parent &&
+			page_in_parent(at[pfn] & PME_SOFT_DIRTY)) {
 			ret = page_pipe_add_hole(pp, vaddr, PP_HOLE_PARENT);
 			pages[1]++;
 		} else {
-- 
1.9.1



More information about the CRIU mailing list