[CRIU] [PATCHv1 3/8] mem: reset SOFT_DIRTY bits after dumping of all vmas in the process

Eugene Batalov eabatalov89 at gmail.com
Wed Dec 16 05:12:11 PST 2015


From: Fyodor Bocharov<bocharovfedor at gmail.com>

Currently CRIU resets SOFT_DIRTY bits immediately after dumping of
anonymous private memory. Anonymous shared memory dumping is performed
later. So SOFT_DIRTY bits are all zeroed at the time of anon shared mem
dumping. This is invalid behavior if we want to track changes in anonymous
shared memory.
This patch changes SOFT_DIRTY bits reset moment. Now SOFT_DIRTY bits reset
is performed after dumping of all VMAs in the process.

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

diff --git a/cr-dump.c b/cr-dump.c
index 7485507..d5ef044 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1120,6 +1120,10 @@ static int pre_dump_one_task(struct pstree_item *item, struct list_head *ctls)
 	if (ret)
 		goto err_cure;
 
+	ret = task_reset_dirty_track(pid);
+	if (ret)
+		goto err_cure;
+
 	if (parasite_cure_remote(parasite_ctl))
 		pr_err("Can't cure (pid: %d) from parasite\n", pid);
 	list_add_tail(&parasite_ctl->pre_list, ctls);
@@ -1336,6 +1340,10 @@ static int dump_one_task(struct pstree_item *item)
 		goto err;
 	}
 
+	ret = task_reset_dirty_track(pid);
+	if (ret)
+		goto err;
+
 	close_cr_imgset(&cr_imgset);
 	exit_code = 0;
 err:
diff --git a/include/mem.h b/include/mem.h
index 5269cad..f6808e0 100644
--- a/include/mem.h
+++ b/include/mem.h
@@ -6,6 +6,7 @@ struct vm_area_list;
 struct page_pipe;
 struct pstree_item;
 
+extern int task_reset_dirty_track(int pid);
 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/mem.c b/mem.c
index 02399fc..78cc2fe 100644
--- a/mem.c
+++ b/mem.c
@@ -24,7 +24,7 @@
 #include "protobuf.h"
 #include "protobuf/pagemap.pb-c.h"
 
-static int task_reset_dirty_track(int pid)
+int task_reset_dirty_track(int pid)
 {
 	if (!opts.track_mem)
 		return 0;
@@ -327,7 +327,6 @@ again:
 	 * Step 4 -- clean up
 	 */
 
-	ret = task_reset_dirty_track(ctl->pid.real);
 out_xfer:
 	if (pp_ret == NULL)
 		xfer.close(&xfer);
-- 
1.9.1



More information about the CRIU mailing list