Commit e3fb9bd9 authored by Adrian Reber's avatar Adrian Reber Committed by Andrei Vagin

lazy-pages: add support to combine pre-copy and post-copy

Only the UFFD daemon is aware if pages are in the parent or not. The
restore will continue to work as any lazy-restore except that pages from
parent checkpoints will be pre-populated by the restorer.

The restorer will still register the whole memory region as being
handled by userfaultfd even if it contains pages from parent
checkpoints. Userfaultfd page faults will only happen on pages which
contain no data. This means from the parent pre-populated pages will not
trigger a userfaultfd message even if marked as being handled by
userfaultfd.

The UFFD daemon knows about pages which are available in the parent
checkpoints and will not push those pages unnecessarily to userfaultfd.

Following steps to migrate a process are now possible:

Source system:

 * criu pre-dump -D /tmp/cp/1 -t <PID>
 * rsync -a /tmp/cp <destination>:/tmp
 * criu dump -D /tmp/cp/2 -t <PID> --port 27 --lazy-pages \
   --prev-images-dir ../1/ --track-mem

Destination system:

 * rsync -a <source>:/tmp/cp /tmp/
 * criu lazy-pages --page-server --address <source> --port 27 \
   -D /tmp/cp/2 &
 * criu restore --lazy-pages -D /tmp/cp/2

This will now restore all pages from the parent checkpoint if they
are not marked as lazy in the second checkpoint.

v2:
 - changed parent detection to use pagemap_in_parent()

v3:
 - unfortunately this reverts
   c11cf95afbe023a2816a3afaecb65cc4fee670d7
   "criu: mem: skip lazy pages during restore based on pagemap info"
   To be able to split the VMA-s in the right chunks for the restorer
   it is necessary to make the decision lazy or not on the VmaEntry
   level.

v4:
 - everything has changed thanks to Mike Rapoport's suggestion
 - the VMA-s are no longer touched or split
 - instead of over 100 lines of changes this is now two line patch
Signed-off-by: 's avatarAdrian Reber <areber@redhat.com>
Acked-by: 's avatarMike Rapoprot <rppt@linux.vnet.ibm.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent c1f0b1f5
......@@ -507,7 +507,8 @@ static int collect_uffd_pages(struct page_read *pr, struct lazy_pages_info *lpi)
*/
if (base >= vma->e->start && base < vma->e->end) {
if (vma_entry_can_be_lazy(vma->e)) {
uffd_page = true;
if(!pagemap_in_parent(pr->pe))
uffd_page = true;
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment