[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120516193450.GA22859@redhat.com>
Date: Wed, 16 May 2012 21:34:50 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: "Eric W. Biederman" <ebiederm@...ssion.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
LKML <linux-kernel@...r.kernel.org>,
Pavel Emelyanov <xemul@...allels.com>,
Cyrill Gorcunov <gorcunov@...nvz.org>,
Louis Rilling <louis.rilling@...labs.com>,
Mike Galbraith <efault@....de>
Subject: Re: [PATCH 2/3] pidns: Guarantee that the pidns init will be the
last pidns process reaped.
On 05/16, Oleg Nesterov wrote:
>
> Hmm. I don't think the patch is 100% correct. Afaics, this needs more
> delay_pidns_leader() checks.
Anyway, if we rely on ->children, can't we make a simpler fix?
Something like below. It can be simplified even more, just to explain
the idea. Perhaps we don't even need the new PF_ flag and we can
re-use ->wait_chldexit.
Oleg.
--- x/kernel/pid_namespace.c
+++ x/kernel/pid_namespace.c
@@ -184,6 +184,22 @@ void zap_pid_ns_processes(struct pid_nam
rc = sys_wait4(-1, NULL, __WALL, NULL);
} while (rc != -ECHILD);
+ current->flags |= PF_DEAD_INIT;
+ for (;;) {
+ bool need_wait;
+
+ __set_current_state(TASK_UNINTERRUPTIBLE);
+ read_lock(&tasklist_lock);
+ need_wait = !list_empty(current->children);
+ read_unlock(&tasklist_lock);
+
+ if (!need_wait)
+ break;
+ schedule();
+ }
+ __set_current_state(TASK_RUNNING);
+ current->flags &= ~PF_DEAD_INIT;
+
if (pid_ns->reboot)
current->signal->group_exit_code = pid_ns->reboot;
--- x/kernel/exit.c
+++ x/kernel/exit.c
@@ -71,6 +71,11 @@ static void __unhash_process(struct task
list_del_rcu(&p->tasks);
list_del_init(&p->sibling);
+
+ if (unlikely(p->real_parent->flags & PF_DEAD_INIT)
+ if (list_empty(&p->real_parent->children))
+ wake_up_process(p->real_parent);
+
__this_cpu_dec(process_counts);
}
list_del_rcu(&p->thread_group);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists