From: Jingxian He hejingxian@huawei.com
In order to improve criu dump and restore performance, enable pin method for exec file mapping.
Conflict:NA Reference:https://gitee.com/src-openeuler/criu/pulls/21
Signed-off-by: Jingxian He hejingxian@huawei.com --- criu/config.c | 4 ++++ criu/crtools.c | 3 ++- criu/include/cr_options.h | 1 + criu/mem.c | 15 ++++++++++++++- 4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/criu/config.c b/criu/config.c index 5d195cb..91e0fa8 100644 --- a/criu/config.c +++ b/criu/config.c @@ -543,6 +543,7 @@ int parse_options(int argc, char **argv, bool *usage_error, { "file-validation", required_argument, 0, 1098 }, { "share-dst-ports", required_argument, 0, 1099 }, { "share-src-ports", required_argument, 0, 1100 }, + { "exec-pin-start", required_argument, 0, 1101 }, BOOL_OPT("with-cpu-affinity", &opts.with_cpu_affinity), BOOL_OPT("pin-memory", &opts.pin_memory), BOOL_OPT("use-fork-pid", &opts.use_fork_pid), @@ -891,6 +892,9 @@ int parse_options(int argc, char **argv, bool *usage_error, case 1100: SET_CHAR_OPTS(share_src_ports, optarg); break; + case 1101: + opts.exec_pin_start = atoi(optarg); + break; case 'V': pr_msg("Version: %s\n", CRIU_VERSION); if (strcmp(CRIU_GITID, "0")) diff --git a/criu/crtools.c b/criu/crtools.c index 35a479f..3e4b0ae 100644 --- a/criu/crtools.c +++ b/criu/crtools.c @@ -490,7 +490,8 @@ usage: " --reserve-ports Reserve src ports in kernel\n" " --use-nft Use nft API instead of iptables cmd in network locking\n" " --parallel Parallel to accellrate dumping speed\n" -" --async-clear-nft Async to clear nft table set" +" --async-clear-nft Async to clear nft table set\n" +" --exec-pin-start Exec file map's pin start index\n" "\n" "Check options:\n" " Without options, "criu check" checks availability of absolutely required\n" diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h index aa519c8..f7301d8 100644 --- a/criu/include/cr_options.h +++ b/criu/include/cr_options.h @@ -190,6 +190,7 @@ struct cr_options { int use_nft; int parallel; int async_clear_nft; + int exec_pin_start; };
extern struct cr_options opts; diff --git a/criu/mem.c b/criu/mem.c index d56f69e..2afd2da 100644 --- a/criu/mem.c +++ b/criu/mem.c @@ -461,6 +461,8 @@ bool should_pin_vmae(VmaEntry *vmae) if (vma_entry_is(vmae, VMA_ANON_PRIVATE)) return true;
+ if (opts.exec_pin_start && vma_entry_is(vmae, VMA_FILE_PRIVATE)) + return true; return false; }
@@ -567,6 +569,7 @@ static int __parasite_dump_pages_seized(struct pstree_item *item, int possible_pid_reuse = 0; bool has_parent; int parent_predump_mode = -1; + int dump_iov;
pr_info("\n"); pr_info("Dumping pages (type: %d pid: %d)\n", CR_FD_PAGES, item->pid->real); @@ -647,9 +650,19 @@ static int __parasite_dump_pages_seized(struct pstree_item *item, if(mdc->parent_ie) parent_predump_mode = mdc->parent_ie->pre_dump_mode;
+ dump_iov = 0; list_for_each_entry(vma_area, &vma_area_list->h, list) { if (opts.pin_memory && should_pin_vmae(vma_area->e)) { - continue; + if (!opts.exec_pin_start) + continue; + else { + if (vma_entry_is(vma_area->e, VMA_FILE_PRIVATE) && ((vma_area->e->prot & PROT_WRITE) || !(vma_area->e->prot & PROT_EXEC))) { + dump_iov++; + if (dump_iov > opts.exec_pin_start + 1) + continue; + } else + continue; + } }
if (vma_entry_is(vma_area->e, VMA_AREA_ANON_INODE))