[CRIU] [PATCHv1 7/8] shmem: implement anon shared memory dedup on dump

Pavel Emelyanov xemul at parallels.com
Thu Dec 17 02:32:10 PST 2015


> @@ -439,10 +410,13 @@ static int dump_one_shmem(struct shmem_info_dump *si)
>  		goto err_pp;
>  
>  	for (pfn = 0; pfn < nrpages; pfn++) {
> -		if (!(map[pfn] & PAGE_RSS))
> -			continue;
> +		unsigned long dirty = test_bit(pfn, si->pdirty_map);
>  again:
> -		ret = page_pipe_add_page(pp, (unsigned long)addr + pfn * PAGE_SIZE);
> +		if (xfer.parent && page_in_parent(dirty))
> +			ret = page_pipe_add_hole(pp, (unsigned long)addr + pfn * PAGE_SIZE);
> +		else
> +			ret = page_pipe_add_page(pp, (unsigned long)addr + pfn * PAGE_SIZE);
> +

This place is incorrect. For the very first dump you would add ALL the
shmem pages into dump, while you should check for page being present
in memory at all. Before the patch it was done by map[pfn] & PAGE_RSS
above. This time you should probably collect those bits in the same manner
as you do for soft-dirty ones.

>  		if (ret == -EAGAIN) {
>  			ret = dump_pages(pp, &xfer, addr);
>  			if (ret)
> @@ -464,7 +438,6 @@ err_iovs:
>  err_unmap:
>  	munmap(addr,  si->size);
>  err:
> -	xfree(map);
>  	return ret;
>  }
>  
> 



More information about the CRIU mailing list