[CRIU] [RFC PATCH] Try to include userfaultfd with criu
Pavel Emelyanov
xemul at parallels.com
Mon Oct 26 12:58:49 PDT 2015
On 10/26/2015 10:49 PM, Adrian Reber wrote:
> On Mon, Oct 26, 2015 at 07:13:06PM +0300, Pavel Emelyanov wrote:
>> On 10/26/2015 03:41 PM, Adrian Reber wrote:
>>> Pavel, thanks for the comments on the userfaultfd integration. I am
>>> trying to integrate all your suggestions. I have question about
>>> restoring pages... Or rather about not restoring pages.
>>>
>>> My current approach is, if the parameter --lazy-pages is specified, to
>>> skip pages with MAP_ANONYMOUS. I thought about skipping the pages in
>>> restore_priv_vma_content().
>>
>> Correct.
>>
>>> If I skip pages I need to seek with a
>>> different value then '0' in read_pagemap_page() to read from the right
>>> position from the pages-x.img file.
>>
>> Yes, there's skip_pagemap_pages() call for that :)
>
> So what do you say to a patch like this:
>
> diff --git a/include/page-read.h b/include/page-read.h
> index 9e3013a..e973426 100644
> --- a/include/page-read.h
> +++ b/include/page-read.h
> @@ -51,6 +51,7 @@ struct page_read {
> /* stop working on current pagemap */
> void (*put_pagemap)(struct page_read *);
> void (*close)(struct page_read *);
> + void (*skip_pages)(struct page_read *, unsigned long len);
>
> /* Private data of reader */
> struct cr_img *pmi;
> diff --git a/page-read.c b/page-read.c
> index 832c057..6c0bb95 100644
> --- a/page-read.c
> +++ b/page-read.c
> @@ -279,6 +279,7 @@ int open_page_read_at(int dfd, int pid, struct page_read *pr, int pr_flags)
> pr->put_pagemap = put_pagemap;
> pr->read_page = read_pagemap_page;
> pr->close = close_page_read;
> + pr->skip_pages = skip_pagemap_pages;
> pr->id = ids++;
>
> pr_debug("Opened page read %u (parent %u)\n",
> @@ -301,6 +302,7 @@ open_old:
> pr->read_page = read_page;
> pr->pi = NULL;
> pr->close = close_page_read;
> + pr->skip_pages = NULL;
>
> return 1;
> }
>
> This way I can use skip pages in cr-restore.c and I am only reading
> the pages I cannot restore via uffd. I could submit this as proper
> patch independent of the uffd functionality.
I'm not 100% sure that just calling this one will work for your case. The
skip_pagemap_pages() skips only in current pagemap and if you _can_
overlap in your code, then this won't work. The seek_pagemap_pages() is
higher level routine that can jump to the next pagemap in the sequence
(again -- if your code needs it).
And even worse %) -- if you have stacked pagemap images you should
correctly skip data from lower levels too, the read_pagemap_page() does
_this_, so if your code doesn't want to mess with it, you should write
something similar.
In the end -- the exact page_read method you'd need to add would depend
on how exactly you access the images and skip data in it.
-- Pavel
More information about the CRIU
mailing list