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

Pavel Emelyanov xemul at parallels.com
Tue Dec 8 04:56:40 PST 2015


On 12/06/2015 04:15 PM, Eugene Batalov wrote:
> From: Fyodor <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     | 7 +++++++
>  include/mem.h | 1 +
>  mem.c         | 3 +--
>  3 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/cr-dump.c b/cr-dump.c
> index 5cc375d..466880e 100644
> --- a/cr-dump.c
> +++ b/cr-dump.c
> @@ -476,8 +476,11 @@ static int dump_task_mm(pid_t pid, const struct proc_pid_stat *stat,
>  		goto err;
>  
>  	ret = pb_write_one(img_from_set(imgset, CR_FD_MM), &mme, PB_MM);
> +	if (!ret)
> +		ret = task_reset_dirty_track(pid);

Plz make it symmetrical with pre_dump_one_task() and reset dirty tracker
for dump somewhere in dump_one_task() routine.

>  	xfree(mme.mm_saved_auxv);
>  	free_aios(&mme);
> +
>  err:
>  	return ret;
>  }
> @@ -1120,6 +1123,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);
> 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 989efc3..e26a0d2 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);
> 



More information about the CRIU mailing list