[CRIU] Re: [PATCH cr 07/11] restorer: remap private vmas to correct places

Pavel Emelyanov xemul at parallels.com
Mon Oct 15 12:28:27 EDT 2012


On 10/15/2012 07:32 PM, Andrey Vagin wrote:
> All private vmas were restored before forking children, but
> in this moment they could not be remapped to correct places,
> because crtools' mappings may conflict with them.
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  cr-restore.c |    2 +-
>  restorer.c   |   24 ++++++++++++++++++++++++
>  2 files changed, 25 insertions(+), 1 deletions(-)
> 
> diff --git a/cr-restore.c b/cr-restore.c
> index 6f465e9..860109c 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -1380,7 +1380,7 @@ static int mark_target_vmas(struct list_head *self_vma_list)
>  		list_for_each_entry(n, &vma_list, list) {
>  			unsigned long start = vma->vma.start;
>  
> -			if (!vma_anon(&n->vma))
> +			if (!vma_priv(&n->vma))

Fix for previous patch?

>  				continue;
>  
>  			if (n->vma.flags & MAP_GROWSDOWN)
> diff --git a/restorer.c b/restorer.c
> index 04337a9..75c09a0 100644
> --- a/restorer.c
> +++ b/restorer.c
> @@ -337,6 +337,30 @@ long __export_restore_task(struct task_restore_core_args *args)
>  		if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR))
>  			continue;
>  
> +		if (!vma_priv(vma_entry))
> +			continue;
> +
> +		va = sys_mremap(vma_entry->shmid,
> +				vma_entry_len(vma_entry), vma_entry_len(vma_entry),
> +				MREMAP_MAYMOVE | MREMAP_FIXED, vma_entry->start);

What if the vma_entry->shmid is busy with another "soon to be remapped" vma?

> +		if (va != vma_entry->start) {
> +			pr_err("Unable to remap %lx -> %lx mapping with %lx\n",
> +				vma_entry->shmid, vma_entry->start, va);
> +			while(1);

?

> +			goto core_restore_end;
> +		}
> +	}
> +
> +	/*
> +	 * OK, lets try to map new one.
> +	 */
> +	for (vma_entry = args->tgt_vmas; vma_entry->start != 0; vma_entry++) {
> +		if (!vma_entry_is(vma_entry, VMA_AREA_REGULAR))
> +			continue;
> +
> +		if (vma_priv(vma_entry))
> +			continue;

Double pass over vmas list. Can we avoid it?

> +
>  		va = restore_mapping(vma_entry);
>  
>  		if (va != vma_entry->start) {
> 




More information about the CRIU mailing list