!26 update to version 3.16.1
Merge pull request !26 from zhouwenpei/openEuler-22.03-LTS-Next
This commit is contained in:
commit
3dc920968a
@ -1,28 +0,0 @@
|
||||
From 22bd1e20cbd3c26d2e5dba76e3b0a95ff0a2e154 Mon Sep 17 00:00:00 2001
|
||||
From: lingsheng <lingsheng@huawei.com>
|
||||
Date: Tue, 22 Sep 2020 14:36:55 +0800
|
||||
Subject: [PATCH 1/6] Fix crit encode TypeError
|
||||
|
||||
---
|
||||
lib/py/cli.py | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/py/cli.py b/lib/py/cli.py
|
||||
index da34302..966dd4e 100755
|
||||
--- a/lib/py/cli.py
|
||||
+++ b/lib/py/cli.py
|
||||
@@ -16,7 +16,10 @@ def inf(opts):
|
||||
|
||||
def outf(opts):
|
||||
if opts['out']:
|
||||
- return open(opts['out'], 'w+')
|
||||
+ if getattr(opts['func'], '__name__') == 'encode':
|
||||
+ return open(opts['out'], 'wb+')
|
||||
+ else:
|
||||
+ return open(opts['out'], 'w+')
|
||||
else:
|
||||
return sys.stdout
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -16,56 +16,62 @@ at restore.
|
||||
|
||||
Signed-off-by: Sang Yan <sangyan@huawei.com>
|
||||
---
|
||||
compel/arch/arm/plugins/std/syscalls/syscall.def | 1 +
|
||||
.../ppc64/plugins/std/syscalls/syscall-ppc64.tbl | 1 +
|
||||
.../s390/plugins/std/syscalls/syscall-s390.tbl | 1 +
|
||||
.../arch/x86/plugins/std/syscalls/syscall_32.tbl | 1 +
|
||||
.../arch/x86/plugins/std/syscalls/syscall_64.tbl | 1 +
|
||||
criu/config.c | 1 +
|
||||
criu/cr-dump.c | 14 ++++++++
|
||||
criu/cr-restore.c | 26 ++++++++++++++
|
||||
criu/crtools.c | 2 ++
|
||||
criu/include/cr_options.h | 2 ++
|
||||
criu/include/restorer.h | 3 ++
|
||||
criu/pie/restorer.c | 38 ++++++++++++++++++++
|
||||
criu/pstree.c | 7 ++++
|
||||
images/core.proto | 5 +++
|
||||
test/zdtm/static/Makefile | 1 +
|
||||
test/zdtm/static/cpu-affinity0.c | 42 ++++++++++++++++++++++
|
||||
test/zdtm/static/cpu-affinity0.desc | 1 +
|
||||
17 files changed, 147 insertions(+)
|
||||
.../arch/arm/plugins/std/syscalls/syscall.def | 1 +
|
||||
.../plugins/std/syscalls/syscall-ppc64.tbl | 1 +
|
||||
.../plugins/std/syscalls/syscall-s390.tbl | 1 +
|
||||
.../x86/plugins/std/syscalls/syscall_32.tbl | 1 +
|
||||
.../x86/plugins/std/syscalls/syscall_64.tbl | 1 +
|
||||
criu/config.c | 1 +
|
||||
criu/cr-dump.c | 13 ++++++
|
||||
criu/cr-restore.c | 23 ++++++++++
|
||||
criu/crtools.c | 2 +
|
||||
criu/include/cr_options.h | 2 +
|
||||
criu/include/restorer.h | 3 ++
|
||||
criu/pie/restorer.c | 38 +++++++++++++++++
|
||||
criu/pstree.c | 7 ++++
|
||||
images/core.proto | 5 +++
|
||||
test/zdtm/static/Makefile | 1 +
|
||||
test/zdtm/static/cpu-affinity0.c | 42 +++++++++++++++++++
|
||||
test/zdtm/static/cpu-affinity0.desc | 1 +
|
||||
17 files changed, 143 insertions(+)
|
||||
create mode 100644 test/zdtm/static/cpu-affinity0.c
|
||||
create mode 100644 test/zdtm/static/cpu-affinity0.desc
|
||||
|
||||
diff --git a/compel/arch/arm/plugins/std/syscalls/syscall.def b/compel/arch/arm/plugins/std/syscalls/syscall.def
|
||||
index f7ebc85..d577373 100644
|
||||
index e6508ed..1b877d1 100644
|
||||
--- a/compel/arch/arm/plugins/std/syscalls/syscall.def
|
||||
+++ b/compel/arch/arm/plugins/std/syscalls/syscall.def
|
||||
@@ -116,3 +116,4 @@ fsopen 430 430 (char *fsname, unsigned int flags)
|
||||
@@ -116,5 +116,6 @@ fsopen 430 430 (char *fsname, unsigned int flags)
|
||||
fsconfig 431 431 (int fd, unsigned int cmd, const char *key, const char *value, int aux)
|
||||
fsmount 432 432 (int fd, unsigned int flags, unsigned int attr_flags)
|
||||
clone3 435 435 (struct clone_args *uargs, size_t size)
|
||||
+sched_setaffinity 122 241 (int fd, size_t cpusetsize, const cpu_set_t *mask)
|
||||
+sched_setaffinity 122 241 (int fd, size_t cpusetsize, const cpu_set_t *mask)
|
||||
pidfd_open 434 434 (pid_t pid, unsigned int flags)
|
||||
pidfd_getfd 438 438 (int pidfd, int targetfd, unsigned int flags)
|
||||
diff --git a/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl b/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
|
||||
index 1afaf1e..fa64545 100644
|
||||
index 1bb626b..dd79187 100644
|
||||
--- a/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
|
||||
+++ b/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
|
||||
@@ -112,3 +112,4 @@ __NR_fsopen 430 sys_fsopen (char *fsname, unsigned int flags)
|
||||
@@ -112,5 +112,6 @@ __NR_fsopen 430 sys_fsopen (char *fsname, unsigned int flags)
|
||||
__NR_fsconfig 431 sys_fsconfig (int fd, unsigned int cmd, const char *key, const char *value, int aux)
|
||||
__NR_fsmount 432 sys_fsmount (int fd, unsigned int flags, unsigned int attr_flags)
|
||||
__NR_clone3 435 sys_clone3 (struct clone_args *uargs, size_t size)
|
||||
+__NR_sched_setaffinity 222 sys_sched_setaffinity (int fd, size_t cpusetsize, const cpu_set_t *mask)
|
||||
+__NR_sched_setaffinity 222 sys_sched_setaffinity (int fd, size_t cpusetsize, const cpu_set_t *mask)
|
||||
__NR_pidfd_open 434 sys_pidfd_open (pid_t pid, unsigned int flags)
|
||||
__NR_pidfd_getfd 438 sys_pidfd_getfd (int pidfd, int targetfd, unsigned int flags)
|
||||
diff --git a/compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl b/compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl
|
||||
index ae6fdb5..16f1994 100644
|
||||
index 7178bf4..282adaf 100644
|
||||
--- a/compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl
|
||||
+++ b/compel/arch/s390/plugins/std/syscalls/syscall-s390.tbl
|
||||
@@ -112,3 +112,4 @@ __NR_fsopen 430 sys_fsopen (char *fsname, unsigned int flags)
|
||||
@@ -112,5 +112,6 @@ __NR_fsopen 430 sys_fsopen (char *fsname, unsigned int flags)
|
||||
__NR_fsconfig 431 sys_fsconfig (int fd, unsigned int cmd, const char *key, const char *value, int aux)
|
||||
__NR_fsmount 432 sys_fsmount (int fd, unsigned int flags, unsigned int attr_flags)
|
||||
__NR_clone3 435 sys_clone3 (struct clone_args *uargs, size_t size)
|
||||
+__NR_sched_setaffinity 239 sys_sched_setaffinity (int fd, size_t cpusetsize, const cpu_set_t *mask)
|
||||
+__NR_sched_setaffinity 239 sys_sched_setaffinity (int fd, size_t cpusetsize, const cpu_set_t *mask)
|
||||
__NR_pidfd_open 434 sys_pidfd_open (pid_t pid, unsigned int flags)
|
||||
__NR_pidfd_getfd 438 sys_pidfd_getfd (int pidfd, int targetfd, unsigned int flags)
|
||||
diff --git a/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl b/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl
|
||||
index 7a48711..29c13e3 100644
|
||||
index 7e456cd..3fe3194 100644
|
||||
--- a/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl
|
||||
+++ b/compel/arch/x86/plugins/std/syscalls/syscall_32.tbl
|
||||
@@ -63,6 +63,7 @@ __NR_mincore 218 sys_mincore (void *addr, unsigned long size, unsigned char *
|
||||
@ -77,7 +83,7 @@ index 7a48711..29c13e3 100644
|
||||
__NR_get_thread_area 244 sys_get_thread_area (user_desc_t *info)
|
||||
__NR_io_setup 245 sys_io_setup (unsigned nr_reqs, aio_context_t *ctx32p)
|
||||
diff --git a/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl b/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
|
||||
index 6667c07..74f5482 100644
|
||||
index 2dfcc6e..c1d119d 100644
|
||||
--- a/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
|
||||
+++ b/compel/arch/x86/plugins/std/syscalls/syscall_64.tbl
|
||||
@@ -73,6 +73,7 @@ __NR_mount 165 sys_mount (char *dev_nmae, char *dir_name, char *type, unsign
|
||||
@ -89,22 +95,22 @@ index 6667c07..74f5482 100644
|
||||
__NR_io_setup 206 sys_io_setup (unsigned nr_events, aio_context_t *ctx)
|
||||
__NR_io_getevents 208 sys_io_getevents (aio_context_t ctx, long min_nr, long nr, struct io_event *evs, struct timespec *tmo)
|
||||
diff --git a/criu/config.c b/criu/config.c
|
||||
index 08606fb..5a53256 100644
|
||||
index 91fb0b6..71f99c9 100644
|
||||
--- a/criu/config.c
|
||||
+++ b/criu/config.c
|
||||
@@ -541,6 +541,7 @@ int parse_options(int argc, char **argv, bool *usage_error,
|
||||
{ "cgroup-yard", required_argument, 0, 1096 },
|
||||
{ "pre-dump-mode", required_argument, 0, 1097},
|
||||
{ "file-validation", required_argument, 0, 1098 },
|
||||
@@ -695,6 +695,7 @@ int parse_options(int argc, char **argv, bool *usage_error, bool *has_exec_cmd,
|
||||
{ "cgroup-yard", required_argument, 0, 1096 },
|
||||
{ "pre-dump-mode", required_argument, 0, 1097 },
|
||||
{ "file-validation", required_argument, 0, 1098 },
|
||||
+ BOOL_OPT("with-cpu-affinity", &opts.with_cpu_affinity),
|
||||
{ },
|
||||
};
|
||||
|
||||
{ "lsm-mount-context", required_argument, 0, 1099 },
|
||||
{ "network-lock", required_argument, 0, 1100 },
|
||||
{},
|
||||
diff --git a/criu/cr-dump.c b/criu/cr-dump.c
|
||||
index b9d2914..f078c27 100644
|
||||
index 940f622..f07fe6e 100644
|
||||
--- a/criu/cr-dump.c
|
||||
+++ b/criu/cr-dump.c
|
||||
@@ -140,6 +140,7 @@ static int dump_sched_info(int pid, ThreadCoreEntry *tc)
|
||||
@@ -139,6 +139,7 @@ static int dump_sched_info(int pid, ThreadCoreEntry *tc)
|
||||
{
|
||||
int ret;
|
||||
struct sched_param sp;
|
||||
@ -112,10 +118,10 @@ index b9d2914..f078c27 100644
|
||||
|
||||
BUILD_BUG_ON(SCHED_OTHER != 0); /* default in proto message */
|
||||
|
||||
@@ -185,6 +186,19 @@ static int dump_sched_info(int pid, ThreadCoreEntry *tc)
|
||||
@@ -183,6 +184,18 @@ static int dump_sched_info(int pid, ThreadCoreEntry *tc)
|
||||
pr_info("\tdumping %d nice for %d\n", ret, pid);
|
||||
tc->has_sched_nice = true;
|
||||
tc->sched_nice = ret;
|
||||
|
||||
+ pr_info("\tdumping allowed cpus for %d\n", pid);
|
||||
+ ret = syscall(__NR_sched_getaffinity, pid, sizeof(cpumask), &cpumask);
|
||||
+ if (ret < 0) {
|
||||
@ -124,16 +130,15 @@ index b9d2914..f078c27 100644
|
||||
+ }
|
||||
+ memcpy(tc->allowed_cpus->cpumask, &cpumask, sizeof(cpu_set_t));
|
||||
+ pr_info("\t 0x%llx, 0x%llx, 0x%llx, 0x%llx\n",
|
||||
+ (unsigned long long)tc->allowed_cpus->cpumask[3],
|
||||
+ (unsigned long long)tc->allowed_cpus->cpumask[2],
|
||||
+ (unsigned long long)tc->allowed_cpus->cpumask[1],
|
||||
+ (unsigned long long)tc->allowed_cpus->cpumask[0]);
|
||||
+
|
||||
+ (unsigned long long)tc->allowed_cpus->cpumask[3],
|
||||
+ (unsigned long long)tc->allowed_cpus->cpumask[2],
|
||||
+ (unsigned long long)tc->allowed_cpus->cpumask[1],
|
||||
+ (unsigned long long)tc->allowed_cpus->cpumask[0]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
|
||||
index 589087f..da2e53d 100644
|
||||
index 9d2d957..5b645c1 100644
|
||||
--- a/criu/cr-restore.c
|
||||
+++ b/criu/cr-restore.c
|
||||
@@ -118,6 +118,7 @@ static int prepare_restorer_blob(void);
|
||||
@ -144,7 +149,7 @@ index 589087f..da2e53d 100644
|
||||
|
||||
/*
|
||||
* Architectures can overwrite this function to restore registers that are not
|
||||
@@ -922,6 +923,9 @@ static int restore_one_alive_task(int pid, CoreEntry *core)
|
||||
@@ -899,6 +900,9 @@ static int restore_one_alive_task(int pid, CoreEntry *core)
|
||||
if (prepare_signals(pid, ta, core))
|
||||
return -1;
|
||||
|
||||
@ -154,7 +159,7 @@ index 589087f..da2e53d 100644
|
||||
if (prepare_posix_timers(pid, ta, core))
|
||||
return -1;
|
||||
|
||||
@@ -3196,6 +3200,27 @@ out:
|
||||
@@ -3153,6 +3157,24 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -168,21 +173,18 @@ index 589087f..da2e53d 100644
|
||||
+
|
||||
+ need_cpu_affinity = rst_mem_alloc(sizeof(int), RM_PRIVATE);
|
||||
+ *need_cpu_affinity = opts.with_cpu_affinity;
|
||||
+
|
||||
+ for (i = 0; i < current->nr_threads; i++) {
|
||||
+ cpumaks = rst_mem_alloc(sizeof(cpu_set_t), RM_PRIVATE);
|
||||
+ if (!cpumaks)
|
||||
+ return -1;
|
||||
+
|
||||
+ memcpy(cpumaks, current->core[i]->thread_core->allowed_cpus->cpumask, sizeof(cpu_set_t));
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
extern void __gcov_flush(void) __attribute__((weak));
|
||||
void __gcov_flush(void) {}
|
||||
|
||||
@@ -3655,6 +3680,7 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
|
||||
void __gcov_flush(void)
|
||||
{
|
||||
@@ -3603,6 +3625,7 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
|
||||
RST_MEM_FIXUP_PPTR(task_args->timerfd);
|
||||
RST_MEM_FIXUP_PPTR(task_args->posix_timers);
|
||||
RST_MEM_FIXUP_PPTR(task_args->siginfo);
|
||||
@ -191,33 +193,33 @@ index 589087f..da2e53d 100644
|
||||
RST_MEM_FIXUP_PPTR(task_args->helpers);
|
||||
RST_MEM_FIXUP_PPTR(task_args->zombies);
|
||||
diff --git a/criu/crtools.c b/criu/crtools.c
|
||||
index 2eb5dba..0f04a85 100644
|
||||
index 6a75cd1..b5a36b9 100644
|
||||
--- a/criu/crtools.c
|
||||
+++ b/criu/crtools.c
|
||||
@@ -441,6 +441,8 @@ usage:
|
||||
" --file-validation METHOD\n"
|
||||
" pass the validation method to be used; argument\n"
|
||||
" can be 'filesize' or 'buildid' (default).\n"
|
||||
+" --with-cpu-affinity Allow to restore cpu affinity. Only for hosts with\n"
|
||||
+" same cpu quantity.\n"
|
||||
"\n"
|
||||
"Check options:\n"
|
||||
" Without options, \"criu check\" checks availability of absolutely required\n"
|
||||
@@ -445,6 +445,8 @@ usage:
|
||||
" --file-validation METHOD\n"
|
||||
" pass the validation method to be used; argument\n"
|
||||
" can be 'filesize' or 'buildid' (default).\n"
|
||||
+ " --with-cpu-affinity Allow to restore cpu affinity. Only for hosts with\n"
|
||||
+ " same cpu quantity.\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 ac1c9e9..fda54a4 100644
|
||||
index a34f8db..3b50e59 100644
|
||||
--- a/criu/include/cr_options.h
|
||||
+++ b/criu/include/cr_options.h
|
||||
@@ -174,6 +174,8 @@ struct cr_options {
|
||||
@@ -188,6 +188,8 @@ struct cr_options {
|
||||
|
||||
/* This stores which method to use for file validation. */
|
||||
int file_validation_method;
|
||||
int file_validation_method;
|
||||
+ /* restore cpu affinity */
|
||||
+ int with_cpu_affinity;
|
||||
+ int with_cpu_affinity;
|
||||
};
|
||||
|
||||
extern struct cr_options opts;
|
||||
diff --git a/criu/include/restorer.h b/criu/include/restorer.h
|
||||
index dfb4e6b..bd6ef6a 100644
|
||||
index 934d60c..c2ef8f0 100644
|
||||
--- a/criu/include/restorer.h
|
||||
+++ b/criu/include/restorer.h
|
||||
@@ -1,6 +1,7 @@
|
||||
@ -229,19 +231,19 @@ index dfb4e6b..bd6ef6a 100644
|
||||
#include <limits.h>
|
||||
#include <sys/resource.h>
|
||||
@@ -162,6 +163,8 @@ struct task_restore_args {
|
||||
siginfo_t *siginfo;
|
||||
unsigned int siginfo_n;
|
||||
siginfo_t *siginfo;
|
||||
unsigned int siginfo_n;
|
||||
|
||||
+ char *allowed_cpus;
|
||||
+ char *allowed_cpus;
|
||||
+
|
||||
struct rst_tcp_sock *tcp_socks;
|
||||
unsigned int tcp_socks_n;
|
||||
struct rst_tcp_sock *tcp_socks;
|
||||
unsigned int tcp_socks_n;
|
||||
|
||||
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
|
||||
index b3d7e2b..c63f96b 100644
|
||||
index 4304691..fbc89fe 100644
|
||||
--- a/criu/pie/restorer.c
|
||||
+++ b/criu/pie/restorer.c
|
||||
@@ -432,6 +432,40 @@ static int restore_signals(siginfo_t *ptr, int nr, bool group)
|
||||
@@ -425,6 +425,40 @@ static int restore_signals(siginfo_t *ptr, int nr, bool group)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -265,10 +267,10 @@ index b3d7e2b..c63f96b 100644
|
||||
+ pid = args->thread_args[i].pid;
|
||||
+ cpumask = &allowed_cpus[i];
|
||||
+ pr_info("Restoring %d allowed_cpus %llx, %llx, %llx, %llx\n", pid,
|
||||
+ (unsigned long long)cpumask->__bits[3],
|
||||
+ (unsigned long long)cpumask->__bits[2],
|
||||
+ (unsigned long long)cpumask->__bits[1],
|
||||
+ (unsigned long long)cpumask->__bits[0]);
|
||||
+ (unsigned long long)cpumask->__bits[3],
|
||||
+ (unsigned long long)cpumask->__bits[2],
|
||||
+ (unsigned long long)cpumask->__bits[1],
|
||||
+ (unsigned long long)cpumask->__bits[0]);
|
||||
+ ret = sys_sched_setaffinity(pid, sizeof(cpu_set_t), cpumask);
|
||||
+ if (ret) {
|
||||
+ pr_err("\t Restore %d cpumask failed.\n", pid);
|
||||
@ -282,7 +284,7 @@ index b3d7e2b..c63f96b 100644
|
||||
static int restore_seccomp_filter(pid_t tid, struct thread_restore_args *args)
|
||||
{
|
||||
unsigned int flags = args->seccomp_force_tsync ? SECCOMP_FILTER_FLAG_TSYNC : 0;
|
||||
@@ -1900,6 +1934,10 @@ long __export_restore_task(struct task_restore_args *args)
|
||||
@@ -1856,6 +1890,10 @@ long __export_restore_task(struct task_restore_args *args)
|
||||
if (ret)
|
||||
goto core_restore_end;
|
||||
|
||||
@ -294,7 +296,7 @@ index b3d7e2b..c63f96b 100644
|
||||
|
||||
rst_tcp_socks_all(args);
|
||||
diff --git a/criu/pstree.c b/criu/pstree.c
|
||||
index a876615..f0d7622 100644
|
||||
index d5080e5..778c884 100644
|
||||
--- a/criu/pstree.c
|
||||
+++ b/criu/pstree.c
|
||||
@@ -58,11 +58,13 @@ CoreEntry *core_entry_alloc(int th, int tsk)
|
||||
@ -312,8 +314,8 @@ index a876615..f0d7622 100644
|
||||
* @groups are dynamic and allocated
|
||||
* on demand.
|
||||
@@ -127,6 +129,11 @@ CoreEntry *core_entry_alloc(int th, int tsk)
|
||||
ce->cap_eff = xptr_pull_s(&m, CR_CAP_SIZE * sizeof(ce->cap_eff[0]));
|
||||
ce->cap_bnd = xptr_pull_s(&m, CR_CAP_SIZE * sizeof(ce->cap_bnd[0]));
|
||||
ce->cap_eff = xptr_pull_s(&m, CR_CAP_SIZE * sizeof(ce->cap_eff[0]));
|
||||
ce->cap_bnd = xptr_pull_s(&m, CR_CAP_SIZE * sizeof(ce->cap_bnd[0]));
|
||||
|
||||
+ core->thread_core->allowed_cpus = xptr_pull(&m, ThreadAllowedcpusEntry);
|
||||
+ thread_allowedcpus_entry__init(core->thread_core->allowed_cpus);
|
||||
@ -324,43 +326,43 @@ index a876615..f0d7622 100644
|
||||
xfree(core);
|
||||
core = NULL;
|
||||
diff --git a/images/core.proto b/images/core.proto
|
||||
index 9e9e393..2981120 100644
|
||||
index b713119..39e7f32 100644
|
||||
--- a/images/core.proto
|
||||
+++ b/images/core.proto
|
||||
@@ -81,6 +81,10 @@ message thread_sas_entry {
|
||||
@@ -83,6 +83,10 @@ message thread_sas_entry {
|
||||
required uint32 ss_flags = 3;
|
||||
}
|
||||
|
||||
+message thread_allowedcpus_entry {
|
||||
+ repeated uint64 cpumask = 1;
|
||||
+ repeated uint64 cpumask = 1;
|
||||
+}
|
||||
+
|
||||
message thread_core_entry {
|
||||
required uint64 futex_rla = 1;
|
||||
required uint32 futex_rla_len = 2;
|
||||
@@ -99,6 +103,7 @@ message thread_core_entry {
|
||||
@@ -101,6 +105,7 @@ message thread_core_entry {
|
||||
|
||||
optional string comm = 13;
|
||||
optional uint64 blk_sigset_extended = 14;
|
||||
+ required thread_allowedcpus_entry allowed_cpus = 15;
|
||||
+ required thread_allowedcpus_entry allowed_cpus = 15;
|
||||
}
|
||||
|
||||
message task_rlimits_entry {
|
||||
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
|
||||
index aae4983..ad8fc6a 100644
|
||||
index c9e6589..70123cf 100644
|
||||
--- a/test/zdtm/static/Makefile
|
||||
+++ b/test/zdtm/static/Makefile
|
||||
@@ -235,6 +235,7 @@ TST_NOFILE := \
|
||||
@@ -246,6 +246,7 @@ TST_NOFILE := \
|
||||
timens_nested \
|
||||
timens_for_kids \
|
||||
zombie_leader \
|
||||
+ cpu-affinity0 \
|
||||
# jobctl00 \
|
||||
|
||||
pkg-config-check = $(shell sh -c 'pkg-config $(1) && echo y')
|
||||
+ cpu-affinity0 \
|
||||
sigtrap \
|
||||
sigtrap01 \
|
||||
change_mnt_context \
|
||||
diff --git a/test/zdtm/static/cpu-affinity0.c b/test/zdtm/static/cpu-affinity0.c
|
||||
new file mode 100644
|
||||
index 0000000..83dee19
|
||||
index 0000000..27afe73
|
||||
--- /dev/null
|
||||
+++ b/test/zdtm/static/cpu-affinity0.c
|
||||
@@ -0,0 +1,42 @@
|
||||
@ -382,7 +384,7 @@ index 0000000..83dee19
|
||||
+
|
||||
+ CPU_ZERO(&old);
|
||||
+ CPU_ZERO(&new);
|
||||
+
|
||||
+
|
||||
+ /* test only 0 core because of CI test env limited */
|
||||
+ CPU_SET(0, &old);
|
||||
+
|
||||
@ -414,5 +416,5 @@ index 0000000..0d0b8ae
|
||||
@@ -0,0 +1 @@
|
||||
+{'dopts': '', 'ropts': '--with-cpu-affinity', 'flags': 'reqrst '}
|
||||
--
|
||||
1.8.3.1
|
||||
2.27.0
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
From be4a5e65791d18d1e26d6299e80a65324c5fc07e Mon Sep 17 00:00:00 2001
|
||||
From: lingsheng <lingsheng@huawei.com>
|
||||
Date: Tue, 22 Sep 2020 14:39:22 +0800
|
||||
Subject: [PATCH 2/6] Fix crit info struct unpack error
|
||||
|
||||
---
|
||||
lib/py/images/images.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/py/images/images.py b/lib/py/images/images.py
|
||||
index 9c8e144..c330b97 100644
|
||||
--- a/lib/py/images/images.py
|
||||
+++ b/lib/py/images/images.py
|
||||
@@ -171,7 +171,7 @@ class entry_handler:
|
||||
|
||||
while True:
|
||||
buf = f.read(4)
|
||||
- if buf == '':
|
||||
+ if len(buf) == 0:
|
||||
break
|
||||
size, = struct.unpack('i', buf)
|
||||
f.seek(size, 1)
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
From 4f139d2803773c86e5cf557c879392e7b79238b3 Mon Sep 17 00:00:00 2001
|
||||
From: lingsheng <lingsheng@huawei.com>
|
||||
Date: Tue, 22 Sep 2020 14:40:35 +0800
|
||||
Subject: [PATCH 3/6] Fix crit x UnicodeDecodeError
|
||||
|
||||
---
|
||||
lib/py/cli.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/py/cli.py b/lib/py/cli.py
|
||||
index 966dd4e..f7bda23 100755
|
||||
--- a/lib/py/cli.py
|
||||
+++ b/lib/py/cli.py
|
||||
@@ -25,7 +25,7 @@ def outf(opts):
|
||||
|
||||
|
||||
def dinf(opts, name):
|
||||
- return open(os.path.join(opts['dir'], name))
|
||||
+ return open(os.path.join(opts['dir'], name), 'rb')
|
||||
|
||||
|
||||
def decode(opts):
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,193 +0,0 @@
|
||||
From 1c34f736caefd92ed6e131c5a4eb1699e2a24e35 Mon Sep 17 00:00:00 2001
|
||||
From: anatasluo <luolongjuna@gmail.com>
|
||||
Date: Fri, 29 Jan 2021 13:48:57 +0000
|
||||
Subject: [PATCH 5/6] vdso: fix segmentation fault caused by char pointer array
|
||||
|
||||
When I compile criu with "make DEBUG=1" and run it to restore my
|
||||
program, it produces a segmentation fault.
|
||||
|
||||
In aarch64, with compile flag "-O0", when criu executes the code in pie,
|
||||
it is unable to visit the content of ARCH_VDSO_SYMBOLS. So I put these
|
||||
variables into the stack.
|
||||
|
||||
Signed-off-by: anatasluo <luolongjuna@gmail.com>
|
||||
---
|
||||
criu/arch/aarch64/include/asm/vdso.h | 17 +++++++++--------
|
||||
criu/arch/arm/include/asm/vdso.h | 9 ++++++---
|
||||
criu/arch/ppc64/include/asm/vdso.h | 34 +++++++++++++++++++++++-----------
|
||||
criu/arch/s390/include/asm/vdso.h | 17 +++++++++++------
|
||||
criu/arch/x86/include/asm/vdso.h | 23 ++++++++++++++++-------
|
||||
criu/pie/util-vdso.c | 2 ++
|
||||
6 files changed, 67 insertions(+), 35 deletions(-)
|
||||
|
||||
diff --git a/criu/arch/aarch64/include/asm/vdso.h b/criu/arch/aarch64/include/asm/vdso.h
|
||||
index 8a65e09..97a2440 100644
|
||||
--- a/criu/arch/aarch64/include/asm/vdso.h
|
||||
+++ b/criu/arch/aarch64/include/asm/vdso.h
|
||||
@@ -16,15 +16,16 @@
|
||||
* Workaround for VDSO array symbol table's relocation.
|
||||
* XXX: remove when compel/piegen will support aarch64.
|
||||
*/
|
||||
-static const char* __maybe_unused aarch_vdso_symbol1 = "__kernel_clock_getres";
|
||||
-static const char* __maybe_unused aarch_vdso_symbol2 = "__kernel_clock_gettime";
|
||||
-static const char* __maybe_unused aarch_vdso_symbol3 = "__kernel_gettimeofday";
|
||||
-static const char* __maybe_unused aarch_vdso_symbol4 = "__kernel_rt_sigreturn";
|
||||
+#define ARCH_VDSO_SYMBOLS_LIST \
|
||||
+ const char* aarch_vdso_symbol1 = "__kernel_clock_getres"; \
|
||||
+ const char* aarch_vdso_symbol2 = "__kernel_clock_gettime"; \
|
||||
+ const char* aarch_vdso_symbol3 = "__kernel_gettimeofday"; \
|
||||
+ const char* aarch_vdso_symbol4 = "__kernel_rt_sigreturn";
|
||||
|
||||
-#define ARCH_VDSO_SYMBOLS \
|
||||
- aarch_vdso_symbol1, \
|
||||
- aarch_vdso_symbol2, \
|
||||
- aarch_vdso_symbol3, \
|
||||
+#define ARCH_VDSO_SYMBOLS \
|
||||
+ aarch_vdso_symbol1, \
|
||||
+ aarch_vdso_symbol2, \
|
||||
+ aarch_vdso_symbol3, \
|
||||
aarch_vdso_symbol4
|
||||
|
||||
extern void write_intraprocedure_branch(unsigned long to, unsigned long from);
|
||||
diff --git a/criu/arch/arm/include/asm/vdso.h b/criu/arch/arm/include/asm/vdso.h
|
||||
index f57790a..e96514e 100644
|
||||
--- a/criu/arch/arm/include/asm/vdso.h
|
||||
+++ b/criu/arch/arm/include/asm/vdso.h
|
||||
@@ -11,8 +11,11 @@
|
||||
*/
|
||||
#define VDSO_SYMBOL_MAX 2
|
||||
#define VDSO_SYMBOL_GTOD 1
|
||||
-#define ARCH_VDSO_SYMBOLS \
|
||||
- "__vdso_clock_gettime", \
|
||||
- "__vdso_gettimeofday"
|
||||
+#define ARCH_VDSO_SYMBOLS_LIST \
|
||||
+ const char* aarch_vdso_symbol1 = "__vdso_clock_gettime"; \
|
||||
+ const char* aarch_vdso_symbol2 = "__vdso_gettimeofday";
|
||||
+#define ARCH_VDSO_SYMBOLS \
|
||||
+ aarch_vdso_symbol1, \
|
||||
+ aarch_vdso_symbol2,
|
||||
|
||||
#endif /* __CR_ASM_VDSO_H__ */
|
||||
diff --git a/criu/arch/ppc64/include/asm/vdso.h b/criu/arch/ppc64/include/asm/vdso.h
|
||||
index 6c92348..fe04336 100644
|
||||
--- a/criu/arch/ppc64/include/asm/vdso.h
|
||||
+++ b/criu/arch/ppc64/include/asm/vdso.h
|
||||
@@ -14,16 +14,28 @@
|
||||
*/
|
||||
#define VDSO_SYMBOL_MAX 10
|
||||
#define VDSO_SYMBOL_GTOD 5
|
||||
-#define ARCH_VDSO_SYMBOLS \
|
||||
- "__kernel_clock_getres", \
|
||||
- "__kernel_clock_gettime", \
|
||||
- "__kernel_get_syscall_map", \
|
||||
- "__kernel_get_tbfreq", \
|
||||
- "__kernel_getcpu", \
|
||||
- "__kernel_gettimeofday", \
|
||||
- "__kernel_sigtramp_rt64", \
|
||||
- "__kernel_sync_dicache", \
|
||||
- "__kernel_sync_dicache_p5", \
|
||||
- "__kernel_time"
|
||||
+#define ARCH_VDSO_SYMBOLS_LIST \
|
||||
+ const char* aarch_vdso_symbol1 = "__kernel_clock_getres"; \
|
||||
+ const char* aarch_vdso_symbol2 = "__kernel_clock_gettime"; \
|
||||
+ const char* aarch_vdso_symbol3 = "__kernel_get_syscall_map"; \
|
||||
+ const char* aarch_vdso_symbol4 = "__kernel_get_tbfreq"; \
|
||||
+ const char* aarch_vdso_symbol5 = "__kernel_getcpu"; \
|
||||
+ const char* aarch_vdso_symbol6 = "__kernel_gettimeofday"; \
|
||||
+ const char* aarch_vdso_symbol7 = "__kernel_sigtramp_rt64"; \
|
||||
+ const char* aarch_vdso_symbol8 = "__kernel_sync_dicache"; \
|
||||
+ const char* aarch_vdso_symbol9 = "__kernel_sync_dicache_p5"; \
|
||||
+ const char* aarch_vdso_symbol10 = "__kernel_time";
|
||||
+
|
||||
+#define ARCH_VDSO_SYMBOLS \
|
||||
+ aarch_vdso_symbol1, \
|
||||
+ aarch_vdso_symbol2, \
|
||||
+ aarch_vdso_symbol3, \
|
||||
+ aarch_vdso_symbol4, \
|
||||
+ aarch_vdso_symbol5, \
|
||||
+ aarch_vdso_symbol6, \
|
||||
+ aarch_vdso_symbol7, \
|
||||
+ aarch_vdso_symbol8, \
|
||||
+ aarch_vdso_symbol9, \
|
||||
+ aarch_vdso_symbol10
|
||||
|
||||
#endif /* __CR_ASM_VDSO_H__ */
|
||||
diff --git a/criu/arch/s390/include/asm/vdso.h b/criu/arch/s390/include/asm/vdso.h
|
||||
index c54d848..ac71f59 100644
|
||||
--- a/criu/arch/s390/include/asm/vdso.h
|
||||
+++ b/criu/arch/s390/include/asm/vdso.h
|
||||
@@ -12,13 +12,18 @@
|
||||
#define VDSO_SYMBOL_GTOD 0
|
||||
|
||||
/*
|
||||
- * This definition is used in pie/util-vdso.c to initialize the vdso symbol
|
||||
+ * These definitions are used in pie/util-vdso.c to initialize the vdso symbol
|
||||
* name string table 'vdso_symbols'
|
||||
*/
|
||||
-#define ARCH_VDSO_SYMBOLS \
|
||||
- "__kernel_gettimeofday", \
|
||||
- "__kernel_clock_gettime", \
|
||||
- "__kernel_clock_getres", \
|
||||
- "__kernel_getcpu"
|
||||
+#define ARCH_VDSO_SYMBOLS_LIST \
|
||||
+ const char* aarch_vdso_symbol1 = "__kernel_gettimeofday"; \
|
||||
+ const char* aarch_vdso_symbol2 = "__kernel_clock_gettime"; \
|
||||
+ const char* aarch_vdso_symbol3 = "__kernel_clock_getres"; \
|
||||
+ const char* aarch_vdso_symbol4 = "__kernel_getcpu";
|
||||
+#define ARCH_VDSO_SYMBOLS \
|
||||
+ aarch_vdso_symbol1, \
|
||||
+ aarch_vdso_symbol2, \
|
||||
+ aarch_vdso_symbol3, \
|
||||
+ aarch_vdso_symbol4
|
||||
|
||||
#endif /* __CR_ASM_VDSO_H__ */
|
||||
diff --git a/criu/arch/x86/include/asm/vdso.h b/criu/arch/x86/include/asm/vdso.h
|
||||
index 28ae2d1..54d1fba 100644
|
||||
--- a/criu/arch/x86/include/asm/vdso.h
|
||||
+++ b/criu/arch/x86/include/asm/vdso.h
|
||||
@@ -35,13 +35,22 @@
|
||||
* vsyscall will be patched again when addressing:
|
||||
* https://github.com/checkpoint-restore/criu/issues/512
|
||||
*/
|
||||
-#define ARCH_VDSO_SYMBOLS \
|
||||
- "__vdso_clock_gettime", \
|
||||
- "__vdso_getcpu", \
|
||||
- "__vdso_gettimeofday", \
|
||||
- "__vdso_time", \
|
||||
- "__kernel_sigreturn", \
|
||||
- "__kernel_rt_sigreturn"
|
||||
+
|
||||
+#define ARCH_VDSO_SYMBOLS_LIST \
|
||||
+ const char* aarch_vdso_symbol1 = "__vdso_clock_gettime"; \
|
||||
+ const char* aarch_vdso_symbol2 = "__vdso_getcpu"; \
|
||||
+ const char* aarch_vdso_symbol3 = "__vdso_gettimeofday"; \
|
||||
+ const char* aarch_vdso_symbol4 = "__vdso_time"; \
|
||||
+ const char* aarch_vdso_symbol5 = "__kernel_sigreturn"; \
|
||||
+ const char* aarch_vdso_symbol6 = "__kernel_rt_sigreturn";
|
||||
+
|
||||
+#define ARCH_VDSO_SYMBOLS \
|
||||
+ aarch_vdso_symbol1, \
|
||||
+ aarch_vdso_symbol2, \
|
||||
+ aarch_vdso_symbol3, \
|
||||
+ aarch_vdso_symbol4, \
|
||||
+ aarch_vdso_symbol5, \
|
||||
+ aarch_vdso_symbol6
|
||||
|
||||
/* "__kernel_vsyscall", */
|
||||
|
||||
diff --git a/criu/pie/util-vdso.c b/criu/pie/util-vdso.c
|
||||
index 58b2768..c717f2d 100644
|
||||
--- a/criu/pie/util-vdso.c
|
||||
+++ b/criu/pie/util-vdso.c
|
||||
@@ -219,6 +219,8 @@ static void parse_elf_symbols(uintptr_t mem, size_t size, Phdr_t *load,
|
||||
struct vdso_symtable *t, uintptr_t dynsymbol_names,
|
||||
Hash_t *hash, Dyn_t *dyn_symtab)
|
||||
{
|
||||
+ ARCH_VDSO_SYMBOLS_LIST
|
||||
+
|
||||
const char *vdso_symbols[VDSO_SYMBOL_MAX] = {
|
||||
ARCH_VDSO_SYMBOLS
|
||||
};
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -1,268 +0,0 @@
|
||||
From 4c11832330e6c7b924b96c7ea70c14025fe0d970 Mon Sep 17 00:00:00 2001
|
||||
From: "fu.lin" <fulin10@huawei.com>
|
||||
Date: Tue, 13 Apr 2021 14:10:23 +0800
|
||||
Subject: [PATCH 6/6] criu: add pin memory method
|
||||
|
||||
We can use the checkpoint and restore in userspace method to dump
|
||||
and restore tasks when updating the kernel. Currently, criu needs
|
||||
dump all memory data of tasks to files. When the memory size is
|
||||
very large (large than 1GiB), the cost time of the dumping data
|
||||
will be very long (more than 1 min).
|
||||
|
||||
We can pin the memory data of tasks and collect the corresponding
|
||||
physical pages mapping info in checkpoint process, and remap the
|
||||
physical pages to restore tasks in restore process.
|
||||
|
||||
Signed-off-by: Jingxian He <hejingxian@huawei.com>
|
||||
---
|
||||
criu/config.c | 1 +
|
||||
criu/cr-restore.c | 5 +++
|
||||
criu/include/cr_options.h | 1 +
|
||||
criu/include/restorer.h | 24 ++++++++++++
|
||||
criu/mem.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++-
|
||||
criu/pie/restorer.c | 21 ++++++++++-
|
||||
6 files changed, 146 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/criu/config.c b/criu/config.c
|
||||
index 5a53256..61b81fa 100644
|
||||
--- a/criu/config.c
|
||||
+++ b/criu/config.c
|
||||
@@ -542,6 +542,7 @@ int parse_options(int argc, char **argv, bool *usage_error,
|
||||
{ "pre-dump-mode", required_argument, 0, 1097},
|
||||
{ "file-validation", required_argument, 0, 1098 },
|
||||
BOOL_OPT("with-cpu-affinity", &opts.with_cpu_affinity),
|
||||
+ BOOL_OPT("pin-memory", &opts.pin_memory),
|
||||
{ },
|
||||
};
|
||||
|
||||
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
|
||||
index da2e53d..ff41976 100644
|
||||
--- a/criu/cr-restore.c
|
||||
+++ b/criu/cr-restore.c
|
||||
@@ -3866,6 +3866,11 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
|
||||
task_args->clone_restore_fn,
|
||||
task_args->thread_args);
|
||||
|
||||
+ if (opts.pin_memory)
|
||||
+ task_args->pin_memory = true;
|
||||
+ else
|
||||
+ task_args->pin_memory = false;
|
||||
+
|
||||
/*
|
||||
* An indirect call to task_restore, note it never returns
|
||||
* and restoring core is extremely destructive.
|
||||
diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h
|
||||
index fda54a4..a4dc5b8 100644
|
||||
--- a/criu/include/cr_options.h
|
||||
+++ b/criu/include/cr_options.h
|
||||
@@ -176,6 +176,7 @@ struct cr_options {
|
||||
int file_validation_method;
|
||||
/* restore cpu affinity */
|
||||
int with_cpu_affinity;
|
||||
+ int pin_memory;
|
||||
};
|
||||
|
||||
extern struct cr_options opts;
|
||||
diff --git a/criu/include/restorer.h b/criu/include/restorer.h
|
||||
index bd6ef6a..fc37e6d 100644
|
||||
--- a/criu/include/restorer.h
|
||||
+++ b/criu/include/restorer.h
|
||||
@@ -225,6 +225,7 @@ struct task_restore_args {
|
||||
int lsm_type;
|
||||
int child_subreaper;
|
||||
bool has_clone3_set_tid;
|
||||
+ bool pin_memory;
|
||||
} __aligned(64);
|
||||
|
||||
/*
|
||||
@@ -317,4 +318,27 @@ enum {
|
||||
#define __r_sym(name) restorer_sym ## name
|
||||
#define restorer_sym(rblob, name) (void*)(rblob + __r_sym(name))
|
||||
|
||||
+#define PIN_MEM_FILE "/dev/pinmem"
|
||||
+#define PIN_MEM_MAGIC 0x59
|
||||
+#define _SET_PIN_MEM_AREA 1
|
||||
+#define _CLEAR_PIN_MEM_AREA 2
|
||||
+#define _REMAP_PIN_MEM_AREA 3
|
||||
+#define _PIN_MEM_IOC_MAX_NR 4
|
||||
+#define SET_PIN_MEM_AREA _IOW(PIN_MEM_MAGIC, _SET_PIN_MEM_AREA, struct pin_mem_area_set)
|
||||
+#define CLEAR_PIN_MEM_AREA _IOW(PIN_MEM_MAGIC, _CLEAR_PIN_MEM_AREA, int)
|
||||
+#define REMAP_PIN_MEM_AREA _IOW(PIN_MEM_MAGIC, _REMAP_PIN_MEM_AREA, int)
|
||||
+
|
||||
+#define ONCE_PIN_MEM_SIZE_LIMIT 32 * 1024 * 1024
|
||||
+#define MAX_PIN_MEM_AREA_NUM 16
|
||||
+struct pin_mem_area {
|
||||
+ unsigned long virt_start;
|
||||
+ unsigned long virt_end;
|
||||
+};
|
||||
+
|
||||
+struct pin_mem_area_set {
|
||||
+ unsigned int pid;
|
||||
+ unsigned int area_num;
|
||||
+ struct pin_mem_area mem_area[MAX_PIN_MEM_AREA_NUM];
|
||||
+};
|
||||
+
|
||||
#endif /* __CR_RESTORER_H__ */
|
||||
diff --git a/criu/mem.c b/criu/mem.c
|
||||
index 167838b..709de4e 100644
|
||||
--- a/criu/mem.c
|
||||
+++ b/criu/mem.c
|
||||
@@ -438,6 +438,88 @@ again:
|
||||
return ret;
|
||||
}
|
||||
|
||||
+bool should_pin_vmae(VmaEntry *vmae)
|
||||
+{
|
||||
+ /*
|
||||
+ * vDSO area must be always dumped because on restore
|
||||
+ * we might need to generate a proxy.
|
||||
+ */
|
||||
+ if (vma_entry_is(vmae, VMA_AREA_VDSO))
|
||||
+ return false;
|
||||
+ /*
|
||||
+ * In turn VVAR area is special and referenced from
|
||||
+ * vDSO area by IP addressing (at least on x86) thus
|
||||
+ * never ever dump its content but always use one provided
|
||||
+ * by the kernel on restore, ie runtime VVAR area must
|
||||
+ * be remapped into proper place..
|
||||
+ */
|
||||
+ if (vma_entry_is(vmae, VMA_AREA_VVAR))
|
||||
+ return false;
|
||||
+
|
||||
+ if (vma_entry_is(vmae, VMA_AREA_AIORING))
|
||||
+ return false;
|
||||
+ if (vma_entry_is(vmae, VMA_ANON_PRIVATE)) {
|
||||
+ pr_debug("find private anon vma: %lx-%lx\n", vmae->start, vmae->end);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static int pin_one_pmas(int fd, unsigned long start,
|
||||
+ unsigned long *pend, struct pstree_item *item)
|
||||
+{
|
||||
+ int ret;
|
||||
+ unsigned int index = 0;
|
||||
+ unsigned long end;
|
||||
+ unsigned long next = start;
|
||||
+ struct pin_mem_area_set pmas;
|
||||
+ struct pin_mem_area *pma;
|
||||
+
|
||||
+ end = *pend;
|
||||
+ while (start < end) {
|
||||
+ next = (start + ONCE_PIN_MEM_SIZE_LIMIT > end) ? end : (start + ONCE_PIN_MEM_SIZE_LIMIT);
|
||||
+ pma = &(pmas.mem_area[index]);
|
||||
+ pma->virt_start = start;
|
||||
+ pma->virt_end = next;
|
||||
+ pr_info("start pin %lx-%lx\n", start, next);
|
||||
+ index++;
|
||||
+ start += ONCE_PIN_MEM_SIZE_LIMIT;
|
||||
+ if (index >= MAX_PIN_MEM_AREA_NUM)
|
||||
+ break;
|
||||
+ }
|
||||
+ *pend = next;
|
||||
+ pmas.area_num = index;
|
||||
+ pmas.pid = vpid(item);
|
||||
+ pr_info("begin pin memory for pid:%d\n", pmas.pid);
|
||||
+ ret = ioctl(fd, SET_PIN_MEM_AREA, &pmas);
|
||||
+ if (ret < 0)
|
||||
+ pr_err("pin mem fail, errno: %s\n", strerror(errno));
|
||||
+ return ret;
|
||||
+}
|
||||
+static int pin_vmae(VmaEntry *vmae, struct pstree_item *item)
|
||||
+{
|
||||
+ int fd;
|
||||
+ int ret = 0;
|
||||
+ unsigned long start, end;
|
||||
+
|
||||
+ fd = open(PIN_MEM_FILE, O_RDWR);
|
||||
+ if (fd < 0) {
|
||||
+ pr_err("open file: %s fail.\n", PIN_MEM_FILE);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ start = vmae->start;
|
||||
+ while (start < vmae->end) {
|
||||
+ end = vmae->end;
|
||||
+ ret = pin_one_pmas(fd, start, &end, item);
|
||||
+ if (ret < 0)
|
||||
+ break;
|
||||
+ start = end;
|
||||
+ }
|
||||
+ close(fd);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
static int __parasite_dump_pages_seized(struct pstree_item *item,
|
||||
struct parasite_dump_pages_args *args,
|
||||
struct vm_area_list *vma_area_list,
|
||||
@@ -513,7 +595,16 @@ static int __parasite_dump_pages_seized(struct pstree_item *item,
|
||||
if (possible_pid_reuse == -1)
|
||||
goto out_xfer;
|
||||
}
|
||||
-
|
||||
+ if (opts.pin_memory) {
|
||||
+ /* pin memory before dump pages */
|
||||
+ list_for_each_entry(vma_area, &vma_area_list->h, list) {
|
||||
+ if (should_pin_vmae(vma_area->e)) {
|
||||
+ ret = pin_vmae(vma_area->e, item);
|
||||
+ if (ret)
|
||||
+ goto out_xfer;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
|
||||
/*
|
||||
* Step 1 -- generate the pagemap
|
||||
@@ -524,6 +615,9 @@ static int __parasite_dump_pages_seized(struct pstree_item *item,
|
||||
parent_predump_mode = mdc->parent_ie->pre_dump_mode;
|
||||
|
||||
list_for_each_entry(vma_area, &vma_area_list->h, list) {
|
||||
+ if (opts.pin_memory && should_pin_vmae(vma_area->e))
|
||||
+ continue;
|
||||
+
|
||||
ret = generate_vma_iovs(item, vma_area, pp, &xfer, args, ctl,
|
||||
&pmc, has_parent, mdc->pre_dump,
|
||||
parent_predump_mode);
|
||||
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
|
||||
index c63f96b..f3bd541 100644
|
||||
--- a/criu/pie/restorer.c
|
||||
+++ b/criu/pie/restorer.c
|
||||
@@ -1414,6 +1414,24 @@ int cleanup_current_inotify_events(struct task_restore_args *task_args)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+int remap_vmas(int pid)
|
||||
+{
|
||||
+ int fd, ret = 0;
|
||||
+
|
||||
+ fd = sys_open(PIN_MEM_FILE, O_RDWR, 0);
|
||||
+ if (fd == -1) {
|
||||
+ pr_err("open file: %s fail.\n", PIN_MEM_FILE);
|
||||
+ return -1;;
|
||||
+ }
|
||||
+
|
||||
+ ret = sys_ioctl(fd, REMAP_PIN_MEM_AREA, (unsigned long) &pid);
|
||||
+ if (ret < 0)
|
||||
+ pr_err("remap pin mem fail for pid: %d\n", pid);
|
||||
+ sys_close(fd);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+
|
||||
/*
|
||||
* The main routine to restore task via sigreturn.
|
||||
* This one is very special, we never return there
|
||||
@@ -1585,7 +1603,8 @@ long __export_restore_task(struct task_restore_args *args)
|
||||
goto core_restore_end;
|
||||
}
|
||||
}
|
||||
-
|
||||
+ if (args->pin_memory)
|
||||
+ remap_vmas(my_pid);
|
||||
/*
|
||||
* Now read the contents (if any)
|
||||
*/
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
Binary file not shown.
BIN
criu-3.16.1.tar.gz
Normal file
BIN
criu-3.16.1.tar.gz
Normal file
Binary file not shown.
27
criu.spec
27
criu.spec
@ -1,12 +1,12 @@
|
||||
Name: criu
|
||||
Version: 3.15
|
||||
Release: 4
|
||||
Version: 3.16.1
|
||||
Release: 1
|
||||
Provides: crtools = %{version}-%{release}
|
||||
Obsoletes: crtools <= 1.0-2
|
||||
Summary: A tool of Checkpoint/Restore in User-space
|
||||
License: GPL-2.0-or-later or LGPL-2.1-only
|
||||
URL: http://criu.org/
|
||||
Source0: http://download.openvz.org/criu/criu-%{version}.tar.bz2
|
||||
Source0: http://github.com/chechpoint-restore/criu/archive/v%{version}/%{name}-%{version}.tar.gz
|
||||
BuildRequires: systemd libnet-devel asciidoc xmlto perl-interpreter libselinux-devel gcc
|
||||
BuildRequires: protobuf-devel protobuf-c-devel python3-devel libnl3-devel libcap-devel
|
||||
Recommends: tar
|
||||
@ -15,12 +15,7 @@ Requires: %{name} = %{version}-%{release}
|
||||
Provides: %{name}-libs = %{version}-%{release}
|
||||
Obsoletes: %{name}-libs < %{version}-%{release}
|
||||
|
||||
Patch0001: 0001-Fix-crit-encode-TypeError.patch
|
||||
Patch0002: 0002-Fix-crit-info-struct-unpack-error.patch
|
||||
Patch0003: 0003-Fix-crit-x-UnicodeDecodeError.patch
|
||||
Patch0004: 0004-criu-dump-and-restore-cpu-affinity-of-each-thread.patch
|
||||
Patch0005: 0005-vdso-fix-segmentation-fault-caused-by-char-pointer-a.patch
|
||||
Patch0006: 0006-criu-add-pin-memory-method.patch
|
||||
Patch1: 0001-criu-dump-and-restore-cpu-affinity-of-each-thread.patch
|
||||
|
||||
%description
|
||||
Checkpoint/Restore in Userspace(CRIU),is a software tool for the linux operating system.
|
||||
@ -50,6 +45,12 @@ Requires: python3-criu = %{version}-%{release}
|
||||
%description -n crit
|
||||
A tool for CRIU image.
|
||||
|
||||
%package -n criu-ns
|
||||
Summary: Tool to run CRIU in different namespaces
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
|
||||
%description -n criu-ns
|
||||
|
||||
%package help
|
||||
Summary: Help documents for criu
|
||||
|
||||
@ -88,12 +89,18 @@ chmod 0755 %{buildroot}/run/%{name}/
|
||||
%files -n crit
|
||||
%{_bindir}/crit
|
||||
|
||||
%files -n criu-ns
|
||||
%{_sbindir}/criu-ns
|
||||
|
||||
%files help
|
||||
%doc README.md COPYING
|
||||
%doc %{_mandir}/man8/criu.8*
|
||||
%doc %{_mandir}/man1/{compel.1*,crit.1*}
|
||||
%doc %{_mandir}/man1/{compel.1*,crit.1*,criu-ns.1*}
|
||||
|
||||
%changelog
|
||||
* Fri Dec 24 2021 zhouwenpei <zhouwenpei11@huawei.com> - 3.16.1-1
|
||||
- upgrade criu version to 3.16.1
|
||||
|
||||
* Tue Sep 07 2021 chenchen <chen_aka_jan@163.com> - 3.15-4
|
||||
- add "-fstack-protector-strong" for libcriu.so.2.0
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user