[CRIU] [PATCH] pidns: Optimize set_next_pid()

Kirill Tkhai ktkhai at virtuozzo.com
Wed May 10 07:26:27 PDT 2017


Do not use pid namespace helper when there is one-level pid.
If it's one-level, then the created task is in root pid ns.
Also, as a parent's level is less or equal a child's,
then parent is in root pid ns too. So, write next pid directly.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/cr-restore.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 3481362b6..073a61983 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -402,7 +402,7 @@ static int set_next_pid(struct ns_id *pid_ns, struct pid *pid)
 {
 	int i, sk, level = pid->level;
 
-	if (!(root_ns_mask & CLONE_NEWPID)) {
+	if (!(root_ns_mask & CLONE_NEWPID) || level == 1) {
 		if (last_level_pid(pid) == INIT_PID)
 			return 0;
 		return __set_next_pid(last_level_pid(pid));



More information about the CRIU mailing list