pidns: Optimize set_next_pid()

Submitted by Kirill Tkhai on May 10, 2017, 2:26 p.m.

Details

Message ID 149442636555.26928.4619718102251262711.stgit@localhost.localdomain
State New
Series "pidns: Optimize set_next_pid()"
Headers show

Commit Message

Kirill Tkhai May 10, 2017, 2:26 p.m.
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@virtuozzo.com>
---
 criu/cr-restore.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

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));

Comments

Andrey Vagin May 12, 2017, 8:59 p.m.
Applied, thanks

On Wed, May 10, 2017 at 05:26:27PM +0300, Kirill Tkhai wrote:
> 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@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));
>