[CRIU] [PATCH 4/6] dump mem: Replace two bools with ctl struct
Pavel Emelyanov
xemul at virtuozzo.com
Mon Sep 19 04:17:45 PDT 2016
This is to make it easier to extend this logic further.
Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
criu/cr-dump.c | 13 ++++++++++---
criu/include/mem.h | 8 ++++++--
criu/mem.c | 28 +++++++++++++---------------
3 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index f5fa730..d845ebd 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -1126,6 +1126,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;
@@ -1175,7 +1176,10 @@ 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, false);
+ mdc.delayed_dump = true;
+ mdc.lazy = false;
+
+ ret = parasite_dump_pages_seized(parasite_ctl, &vmas, &mdc);
if (ret)
goto err_cure;
@@ -1202,6 +1206,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;
@@ -1331,8 +1336,10 @@ static int dump_one_task(struct pstree_item *item)
}
}
- ret = parasite_dump_pages_seized(parasite_ctl, &vmas, opts.lazy_pages,
- opts.lazy_pages);
+ mdc.delayed_dump = opts.lazy_pages;
+ mdc.lazy = opts.lazy_pages;
+
+ ret = parasite_dump_pages_seized(parasite_ctl, &vmas, &mdc);
if (ret)
goto err_cure;
diff --git a/criu/include/mem.h b/criu/include/mem.h
index 1461d2a..4b18af1 100644
--- a/criu/include/mem.h
+++ b/criu/include/mem.h
@@ -10,6 +10,11 @@ struct vm_area_list;
struct page_pipe;
struct pstree_item;
+struct mem_dump_ctl {
+ bool delayed_dump;
+ bool lazy;
+};
+
extern bool page_is_zero(u64 pme);
extern bool page_in_parent(bool dirty);
extern int prepare_mm_pid(struct pstree_item *i);
@@ -17,8 +22,7 @@ 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,
- bool lazy);
+ struct mem_dump_ctl *mdc);
#define PME_PRESENT (1ULL << 63)
#define PME_SWAP (1ULL << 62)
diff --git a/criu/mem.c b/criu/mem.c
index 9043254..c38f793 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -279,7 +279,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, bool lazy)
+ struct mem_dump_ctl *mdc)
{
pmc_t pmc = PMC_INIT;
struct page_pipe *pp;
@@ -288,7 +288,7 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl,
int ret = -1;
unsigned cpp_flags = 0;
unsigned long pmc_size;
- bool should_xfer = (!delayed_dump || lazy);
+ bool should_xfer = (!mdc->delayed_dump || mdc->lazy);
pr_info("\n");
pr_info("Dumping pages (type: %d pid: %d)\n", CR_FD_PAGES, ctl->pid.real);
@@ -310,12 +310,12 @@ 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;
if (!seized_native(ctl))
cpp_flags |= PP_COMPAT;
ctl->mem_pp = pp = create_page_pipe(vma_area_list->priv_size,
- lazy ? NULL : pargs_iovs(args),
+ mdc->lazy ? NULL : pargs_iovs(args),
cpp_flags);
if (!pp)
goto out;
@@ -346,7 +346,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;
}
@@ -361,7 +361,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, false);
if (!ret) {
@@ -374,10 +374,10 @@ again:
goto out_xfer;
}
- if (lazy)
+ if (mdc->lazy)
memcpy(pargs_iovs(args), pp->iovs,
sizeof(struct iovec) * pp->nr_iovs);
- ret = dump_pages(pp, ctl, args, should_xfer ? &xfer : NULL, lazy);
+ ret = dump_pages(pp, ctl, args, should_xfer ? &xfer : NULL, mdc->lazy);
if (ret)
goto out_xfer;
@@ -392,7 +392,7 @@ out_xfer:
if (should_xfer)
xfer.close(&xfer);
out_pp:
- if (ret || !delayed_dump)
+ if (ret || !mdc->delayed_dump)
destroy_page_pipe(pp);
out:
pmc_fini(&pmc);
@@ -401,13 +401,13 @@ out:
}
int parasite_dump_pages_seized(struct parasite_ctl *ctl,
- struct vm_area_list *vma_area_list, bool delayed_dump,
- bool lazy)
+ 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
@@ -429,9 +429,7 @@ int parasite_dump_pages_seized(struct parasite_ctl *ctl,
return -1;
}
- ret = __parasite_dump_pages_seized(ctl, pargs, vma_area_list,
- delayed_dump, lazy);
-
+ 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() */
--
2.5.0
More information about the CRIU
mailing list