mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
dump mem: Replace two bools with ctl struct
This is to make it easier to extend this logic further. Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Acked-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
This commit is contained in:
@@ -1109,6 +1109,7 @@ static int pre_dump_one_task(struct pstree_item *item)
|
||||
struct parasite_ctl *parasite_ctl;
|
||||
int ret = -1;
|
||||
struct parasite_dump_misc misc;
|
||||
struct mem_dump_ctl mdc;
|
||||
|
||||
INIT_LIST_HEAD(&vmas.h);
|
||||
vmas.nr = 0;
|
||||
@@ -1158,7 +1159,9 @@ static int pre_dump_one_task(struct pstree_item *item)
|
||||
|
||||
parasite_ctl->pid.virt = item->pid.virt = misc.pid;
|
||||
|
||||
ret = parasite_dump_pages_seized(parasite_ctl, &vmas, true);
|
||||
mdc.delayed_dump = true;
|
||||
|
||||
ret = parasite_dump_pages_seized(parasite_ctl, &vmas, &mdc);
|
||||
if (ret)
|
||||
goto err_cure;
|
||||
|
||||
@@ -1185,6 +1188,7 @@ static int dump_one_task(struct pstree_item *item)
|
||||
struct cr_imgset *cr_imgset = NULL;
|
||||
struct parasite_drain_fd *dfds = NULL;
|
||||
struct proc_posix_timers_stat proc_args;
|
||||
struct mem_dump_ctl mdc;
|
||||
|
||||
INIT_LIST_HEAD(&vmas.h);
|
||||
vmas.nr = 0;
|
||||
@@ -1314,7 +1318,9 @@ static int dump_one_task(struct pstree_item *item)
|
||||
}
|
||||
}
|
||||
|
||||
ret = parasite_dump_pages_seized(parasite_ctl, &vmas, false);
|
||||
mdc.delayed_dump = false;
|
||||
|
||||
ret = parasite_dump_pages_seized(parasite_ctl, &vmas, &mdc);
|
||||
if (ret)
|
||||
goto err_cure;
|
||||
|
||||
|
@@ -10,13 +10,17 @@ struct vm_area_list;
|
||||
struct page_pipe;
|
||||
struct pstree_item;
|
||||
|
||||
struct mem_dump_ctl {
|
||||
bool delayed_dump;
|
||||
};
|
||||
|
||||
extern bool page_in_parent(bool dirty);
|
||||
extern int prepare_mm_pid(struct pstree_item *i);
|
||||
extern int do_task_reset_dirty_track(int pid);
|
||||
extern unsigned int dump_pages_args_size(struct vm_area_list *vmas);
|
||||
extern int parasite_dump_pages_seized(struct parasite_ctl *ctl,
|
||||
struct vm_area_list *vma_area_list,
|
||||
bool delayed_dump);
|
||||
struct mem_dump_ctl *mdc);
|
||||
|
||||
#define PME_PRESENT (1ULL << 63)
|
||||
#define PME_SWAP (1ULL << 62)
|
||||
|
25
criu/mem.c
25
criu/mem.c
@@ -260,7 +260,7 @@ static int dump_pages(struct page_pipe *pp, struct parasite_ctl *ctl,
|
||||
static int __parasite_dump_pages_seized(struct parasite_ctl *ctl,
|
||||
struct parasite_dump_pages_args *args,
|
||||
struct vm_area_list *vma_area_list,
|
||||
bool delayed_dump)
|
||||
struct mem_dump_ctl *mdc)
|
||||
{
|
||||
pmc_t pmc = PMC_INIT;
|
||||
struct page_pipe *pp;
|
||||
@@ -290,14 +290,14 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl,
|
||||
return -1;
|
||||
|
||||
ret = -1;
|
||||
if (!delayed_dump)
|
||||
if (!mdc->delayed_dump)
|
||||
cpp_flags |= PP_CHUNK_MODE;
|
||||
ctl->mem_pp = pp = create_page_pipe(vma_area_list->priv_size,
|
||||
pargs_iovs(args), cpp_flags);
|
||||
if (!pp)
|
||||
goto out;
|
||||
|
||||
if (!delayed_dump) {
|
||||
if (!mdc->delayed_dump) {
|
||||
ret = open_page_xfer(&xfer, CR_FD_PAGEMAP, ctl->pid.virt);
|
||||
if (ret < 0)
|
||||
goto out_pp;
|
||||
@@ -323,7 +323,7 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl,
|
||||
!vma_area_is(vma_area, VMA_ANON_SHARED))
|
||||
continue;
|
||||
if (vma_entry_is(vma_area->e, VMA_AREA_AIORING)) {
|
||||
if (delayed_dump)
|
||||
if (mdc->delayed_dump)
|
||||
continue;
|
||||
has_parent = false;
|
||||
}
|
||||
@@ -338,7 +338,7 @@ again:
|
||||
ret = generate_iovs(vma_area, pp, map, &off,
|
||||
has_parent);
|
||||
if (ret == -EAGAIN) {
|
||||
BUG_ON(delayed_dump);
|
||||
BUG_ON(mdc->delayed_dump);
|
||||
|
||||
ret = dump_pages(pp, ctl, args, &xfer);
|
||||
if (!ret) {
|
||||
@@ -351,7 +351,7 @@ again:
|
||||
goto out_xfer;
|
||||
}
|
||||
|
||||
ret = dump_pages(pp, ctl, args, delayed_dump ? NULL : &xfer);
|
||||
ret = dump_pages(pp, ctl, args, mdc->delayed_dump ? NULL : &xfer);
|
||||
if (ret)
|
||||
goto out_xfer;
|
||||
|
||||
@@ -363,10 +363,10 @@ again:
|
||||
|
||||
ret = task_reset_dirty_track(ctl->pid.real);
|
||||
out_xfer:
|
||||
if (!delayed_dump)
|
||||
if (!mdc->delayed_dump)
|
||||
xfer.close(&xfer);
|
||||
out_pp:
|
||||
if (ret || !delayed_dump)
|
||||
if (ret || !mdc->delayed_dump)
|
||||
destroy_page_pipe(pp);
|
||||
out:
|
||||
pmc_fini(&pmc);
|
||||
@@ -375,12 +375,13 @@ out:
|
||||
}
|
||||
|
||||
int parasite_dump_pages_seized(struct parasite_ctl *ctl,
|
||||
struct vm_area_list *vma_area_list, bool delayed_dump)
|
||||
struct vm_area_list *vma_area_list,
|
||||
struct mem_dump_ctl *mdc)
|
||||
{
|
||||
int ret;
|
||||
struct parasite_dump_pages_args *pargs;
|
||||
|
||||
pargs = prep_dump_pages_args(ctl, vma_area_list, delayed_dump);
|
||||
pargs = prep_dump_pages_args(ctl, vma_area_list, mdc->delayed_dump);
|
||||
|
||||
/*
|
||||
* Add PROT_READ protection for all VMAs we're about to
|
||||
@@ -402,9 +403,7 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl,
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = __parasite_dump_pages_seized(ctl, pargs, vma_area_list,
|
||||
delayed_dump);
|
||||
|
||||
ret = __parasite_dump_pages_seized(ctl, pargs, vma_area_list, mdc);
|
||||
if (ret) {
|
||||
pr_err("Can't dump page with parasite\n");
|
||||
/* Parasite will unprotect VMAs after fail in fini() */
|
||||
|
Reference in New Issue
Block a user