Commit 33696ceb authored by Adrian Reber's avatar Adrian Reber Committed by Andrei Vagin

uffd.c: do not call unneeded functions

For a lazy restore via userfaultfd the lazy-pages daemon
needs to know which pages exist, so that it knows when all
pages have finally been migrated so that the restored process
has all of its memory. Therefore it needs to know which pages
exist and it needs to parse the files in the dump result directory.

The existing criu functions are designed to be used by a 'normal'
restore and thus a lot of assumptions are made what has to be set up.

For the lazy-pages restore the complete 'restore' initialization is
not necessary and therefore the criu common code dependencies are
minimized with this commit.
Signed-off-by: 's avatarAdrian Reber <areber@redhat.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent b8f46c36
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "include/criu-plugin.h" #include "include/criu-plugin.h"
#include "include/pagemap.h" #include "include/pagemap.h"
#include "include/files-reg.h" #include "include/files-reg.h"
#include "include/kerndat.h"
#include "include/mem.h" #include "include/mem.h"
#include "include/uffd.h" #include "include/uffd.h"
#include "include/util-pie.h" #include "include/util-pie.h"
...@@ -427,18 +428,69 @@ static int handle_vdso_pages(int uffd, struct list_head *uffd_list, unsigned lon ...@@ -427,18 +428,69 @@ static int handle_vdso_pages(int uffd, struct list_head *uffd_list, unsigned lon
} }
/* /*
* Setting up criu infrastructure to easily * Setting up criu infrastructure and scan for VMAs.
* access the dump results.
*/ */
static void criu_init() static int find_vmas()
{ {
/* TODO: return code checking */ struct cr_img *img;
check_img_inventory(); int ret;
prepare_task_entries(); struct vm_area_list vmas;
prepare_pstree(); int vn = 0;
collect_remaps_and_regfiles(); struct rst_info *ri;
prepare_shared_reg_files();
prepare_mm_pid(root_item); LIST_HEAD(uffd_list);
if (check_img_inventory() == -1)
return -1;
vm_area_list_init(&vmas);
/* Allocate memory for task_entries */
if (prepare_task_entries() == -1)
return -1;
if (prepare_pstree() == -1)
return -1;
ri = rsti(root_item);
if (!ri)
return -1;
img = open_image(CR_FD_MM, O_RSTR, pid);
if (!img)
return -1;
ret = pb_read_one_eof(img, &ri->mm, PB_MM);
close_image(img);
if (ret == -1)
return -1;
pr_debug("Found %zd VMAs in image\n", ri->mm->n_vmas);
while (vn < ri->mm->n_vmas) {
struct vma_area *vma;
ret = -1;
vma = alloc_vma_area();
if (!vma)
break;
ret = 0;
ri->vmas.nr++;
vma->e = ri->mm->vmas[vn++];
list_add_tail(&vma->list, &ri->vmas.h);
if (vma_area_is_private(vma, kdat.task_size)) {
vmas.priv_size += vma_area_len(vma);
if (vma->e->flags & MAP_GROWSDOWN)
vmas.priv_size += PAGE_SIZE;
}
pr_info("vma 0x%"PRIx64" 0x%"PRIx64"\n", vma->e->start, vma->e->end);
}
return ret;
} }
int uffd_listen() int uffd_listen()
...@@ -478,8 +530,12 @@ int uffd_listen() ...@@ -478,8 +530,12 @@ int uffd_listen()
uffd_flags = fcntl(uffd, F_GETFD, NULL); uffd_flags = fcntl(uffd, F_GETFD, NULL);
pr_debug("uffd_flags are 0x%x\n", uffd_flags); pr_debug("uffd_flags are 0x%x\n", uffd_flags);
/* Setting up criu infrastructure to easily access the dump results */ /*
criu_init(); * Find the memory pages belonging to the restored process
* so that it is trackable when all pages have been transferred.
*/
if (find_vmas() == -1)
return -1;
/* Initialize FD sets for read() with timeouts (using select()) */ /* Initialize FD sets for read() with timeouts (using select()) */
FD_ZERO(&set); FD_ZERO(&set);
......
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