[CRIU] [PATCH 7/8] parasite: execute only one parasite commend for dumping per-thread data

Andrey Vagin avagin at openvz.org
Thu Jul 11 05:46:54 EDT 2013


We use two commands to get task registers safely. The first command
blocked signals, then crtools dumped registers and all per-thread data
and the the second command unblocks signals.

Currently signals can be blocked with help SETSIGMASK, so we need only
one command to dump per-thread data.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/parasite.h |  4 +---
 parasite-syscall.c | 14 +++-----------
 pie/parasite.c     | 30 ++++--------------------------
 3 files changed, 8 insertions(+), 40 deletions(-)

diff --git a/include/parasite.h b/include/parasite.h
index 334e31d..68c7161 100644
--- a/include/parasite.h
+++ b/include/parasite.h
@@ -24,7 +24,7 @@ enum {
 	PARASITE_CMD_ACK,
 
 	PARASITE_CMD_INIT,
-	PARASITE_CMD_INIT_THREAD,
+	PARASITE_CMD_DUMP_THREAD,
 
 	/*
 	 * These two must be greater than INITs.
@@ -34,7 +34,6 @@ enum {
 
 	PARASITE_CMD_CFG_LOG,
 	PARASITE_CMD_FINI,
-	PARASITE_CMD_FINI_THREAD,
 
 	PARASITE_CMD_MPROTECT_VMAS,
 	PARASITE_CMD_DUMPPAGES,
@@ -164,7 +163,6 @@ struct parasite_dump_creds {
 struct parasite_dump_thread {
 	unsigned int		*tid_addr;
 	pid_t			tid;
-	k_rtsigset_t		blocked;
 	u32			tls;
 	stack_t			sas;
 };
diff --git a/parasite-syscall.c b/parasite-syscall.c
index e8b690f..4533f14 100644
--- a/parasite-syscall.c
+++ b/parasite-syscall.c
@@ -506,7 +506,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, int id,
 		return -1;
 	}
 
-	ret = parasite_execute_trap_by_pid(PARASITE_CMD_INIT_THREAD, ctl,
+	ret = parasite_execute_trap_by_pid(PARASITE_CMD_DUMP_THREAD, ctl,
 					pid, &regs_orig,
 					ctl->r_thread_stack,
 			(k_rtsigset_t *) &core->thread_core->blk_sigset);
@@ -516,18 +516,10 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, int id,
 	}
 
 	ret = get_task_regs(pid, regs_orig, core);
-	if (ret)
+	if (ret) {
 		pr_err("Can't obtain regs for thread %d\n", pid);
-
-	if (parasite_execute_trap_by_pid(PARASITE_CMD_FINI_THREAD, ctl,
-					pid, &regs_orig,
-					ctl->r_thread_stack,
-			(k_rtsigset_t *) &core->thread_core->blk_sigset)) {
-		pr_err("Can't init thread in parasite %d\n", pid);
 		return -1;
 	}
-	if (ret)
-		return -1;
 
 	BUG_ON(!core->thread_core->sas);
 	copy_sas(core->thread_core->sas, &args->sas);
@@ -536,7 +528,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, int id,
 	tid->virt = args->tid;
 	core_put_tls(core, args->tls);
 
-	return ret;
+	return 0;
 }
 
 int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_fdset *cr_fdset)
diff --git a/pie/parasite.c b/pie/parasite.c
index eb5186d..4ceeb3e 100644
--- a/pie/parasite.c
+++ b/pie/parasite.c
@@ -203,41 +203,21 @@ static int drain_fds(struct parasite_drain_fd *args)
 	return ret;
 }
 
-static int init_thread(struct parasite_dump_thread *args)
+static int dump_thread(struct parasite_dump_thread *args)
 {
-	k_rtsigset_t to_block;
 	pid_t tid = sys_gettid();
 	int ret;
 
-	ksigfillset(&to_block);
-	ret = sys_sigprocmask(SIG_SETMASK, &to_block,
-			      &args->blocked,
-			      sizeof(k_rtsigset_t));
-	if (ret)
-		return -1;
-
 	ret = sys_prctl(PR_GET_TID_ADDRESS, (unsigned long) &args->tid_addr, 0, 0, 0);
 	if (ret)
-		goto err;
+		return ret;
 
 	args->tid = tid;
 	args->tls = arch_get_tls();
 
 	ret = sys_sigaltstack(NULL, &args->sas);
-	if (ret)
-		goto err;
 
 	return ret;
-err:
-	sys_sigprocmask(SIG_SETMASK, &args->blocked,
-				NULL, sizeof(k_rtsigset_t));
-	return ret;
-}
-
-static int fini_thread(struct parasite_dump_thread *args)
-{
-	return sys_sigprocmask(SIG_SETMASK, &args->blocked,
-				NULL, sizeof(k_rtsigset_t));
 }
 
 static int init(struct parasite_init_args *args)
@@ -569,10 +549,8 @@ int __used parasite_service(unsigned int cmd, void *args)
 	switch (cmd) {
 	case PARASITE_CMD_INIT:
 		return init(args);
-	case PARASITE_CMD_INIT_THREAD:
-		return init_thread(args);
-	case PARASITE_CMD_FINI_THREAD:
-		return fini_thread(args);
+	case PARASITE_CMD_DUMP_THREAD:
+		return dump_thread(args);
 	case PARASITE_CMD_CFG_LOG:
 		return parasite_cfg_log(args);
 	case PARASITE_CMD_DAEMONIZE:
-- 
1.8.3.1



More information about the CRIU mailing list