diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-08-01 18:03:42 -0400 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-11-19 08:59:12 -0500 |
commit | af4b8a83add95ef40716401395b44a1b579965f4 (patch) | |
tree | 2f3f606b7327f74c1c1beb8a75886318c51c838a /kernel/pid.c | |
parent | 5e1182deb81ae8c68494017c4a8a71811659c870 (diff) |
pidns: Wait in zap_pid_ns_processes until pid_ns->nr_hashed == 1
Looking at pid_ns->nr_hashed is a bit simpler and it works for
disjoint process trees that an unshare or a join of a pid_namespace
may create.
Acked-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'kernel/pid.c')
-rw-r--r-- | kernel/pid.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/kernel/pid.c b/kernel/pid.c index 9c219117af36..6e8da291de49 100644 --- a/kernel/pid.c +++ b/kernel/pid.c | |||
@@ -273,10 +273,20 @@ void free_pid(struct pid *pid) | |||
273 | spin_lock_irqsave(&pidmap_lock, flags); | 273 | spin_lock_irqsave(&pidmap_lock, flags); |
274 | for (i = 0; i <= pid->level; i++) { | 274 | for (i = 0; i <= pid->level; i++) { |
275 | struct upid *upid = pid->numbers + i; | 275 | struct upid *upid = pid->numbers + i; |
276 | struct pid_namespace *ns = upid->ns; | ||
276 | hlist_del_rcu(&upid->pid_chain); | 277 | hlist_del_rcu(&upid->pid_chain); |
277 | if (--upid->ns->nr_hashed == 0) { | 278 | switch(--ns->nr_hashed) { |
278 | upid->ns->nr_hashed = -1; | 279 | case 1: |
279 | schedule_work(&upid->ns->proc_work); | 280 | /* When all that is left in the pid namespace |
281 | * is the reaper wake up the reaper. The reaper | ||
282 | * may be sleeping in zap_pid_ns_processes(). | ||
283 | */ | ||
284 | wake_up_process(ns->child_reaper); | ||
285 | break; | ||
286 | case 0: | ||
287 | ns->nr_hashed = -1; | ||
288 | schedule_work(&ns->proc_work); | ||
289 | break; | ||
280 | } | 290 | } |
281 | } | 291 | } |
282 | spin_unlock_irqrestore(&pidmap_lock, flags); | 292 | spin_unlock_irqrestore(&pidmap_lock, flags); |