[CRIU] [PATCH 07/12] restore: map taks_args and thread_args earlier

Pavel Emelyanov xemul at parallels.com
Tue Dec 18 12:46:38 EST 2012


On 12/18/2012 10:36 AM, Andrey Vagin wrote:
> A task_args saves a number of shared pending signals and
> thread_args save a number of private pendign signals.
> 
> All signal images should be read for determing a size of siginfo-s.

And how does mapping a part of the restorer area help?

> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  cr-restore.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/cr-restore.c b/cr-restore.c
> index cb4d943..1b39f97 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -1630,6 +1630,20 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
>  			current->nr_threads,
>  			KBYTES(restore_thread_vma_len));
>  
> +	/* VMA we need to run task_restore code */
> +	mem = mmap(NULL,
> +			restore_task_vma_len + restore_thread_vma_len,
> +			PROT_READ | PROT_WRITE,
> +			MAP_PRIVATE | MAP_ANON, 0, 0);
> +	if (mem == MAP_FAILED) {
> +		pr_err("Can't mmap section for restore code\n");
> +		goto err;
> +	}
> +
> +	memzero(mem, restore_task_vma_len + restore_thread_vma_len);
> +	task_args	= mem;
> +	thread_args	= mem + restore_task_vma_len;
> +
>  	restore_bootstrap_len = restorer_len +
>  				restore_task_vma_len +
>  				restore_thread_vma_len +
> @@ -1673,16 +1687,14 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
>  	exec_mem_hint += restorer_len;
>  
>  	/* VMA we need to run task_restore code */
> -	mem = mmap((void *)exec_mem_hint,
> +	mem = mremap(mem, restore_task_vma_len + restore_thread_vma_len,
>  			restore_task_vma_len + restore_thread_vma_len,
> -			PROT_READ | PROT_WRITE,
> -			MAP_PRIVATE | MAP_ANON | MAP_FIXED, 0, 0);
> +			MREMAP_FIXED | MREMAP_MAYMOVE, (void *)exec_mem_hint);
>  	if (mem != (void *)exec_mem_hint) {
>  		pr_err("Can't mmap section for restore code\n");
>  		goto err;
>  	}
>  
> -	memzero(mem, restore_task_vma_len + restore_thread_vma_len);
>  	task_args	= mem;
>  	thread_args	= mem + restore_task_vma_len;
>  
> 




More information about the CRIU mailing list