Messages in this thread Patch in this message | | | Date | Sun, 14 Dec 2003 23:28:47 +0100 (CET) | From | Ingo Molnar <> | Subject | Re: [patch] Re: Problem with exiting threads under NPTL |
| |
here's yet another variant of the patch. Changes relative to yours:
- it sets zap_leader to 0 outside the critical section.
- it doesnt set leader to TASK_DEAD, exit_signal == -1 should really protect it from sys_wait4() i believe.
- it sets 'p = leader' within the unlikely branch - slightly faster common case.
the patch testbooted fine here.
Ingo
--- linux/kernel/exit.c.orig +++ linux/kernel/exit.c @@ -50,8 +50,11 @@ static void __unhash_process(struct task void release_task(struct task_struct * p) { task_t *leader; + int zap_leader; struct dentry *proc_dentry; - + +repeat: + zap_leader = 0; BUG_ON(p->state < TASK_ZOMBIE); atomic_dec(&p->user->processes); @@ -72,8 +75,16 @@ void release_task(struct task_struct * p */ leader = p->group_leader; if (leader != p && thread_group_empty(leader) && - leader->state == TASK_ZOMBIE && leader->exit_signal != -1) + leader->state == TASK_ZOMBIE && leader->exit_signal != -1) { do_notify_parent(leader, leader->exit_signal); + /* + * If we were the last child thread and the leader has + * exited already, and the leader's parent ignores SIGCHLD, + * then we are the one who should release the leader. + */ + if (leader->exit_signal == -1) + zap_leader = 1; + } p->parent->cutime += p->utime + p->cutime; p->parent->cstime += p->stime + p->cstime; @@ -88,6 +99,16 @@ void release_task(struct task_struct * p proc_pid_flush(proc_dentry); release_thread(p); put_task_struct(p); + + /* + * Do this outside the tasklist lock. The reference to the + * leader is safe. There's no recursion possible, since + * the leader of the leader is itself: + */ + if (unlikely(zap_leader)) { + p = leader; + goto repeat; + } } /* we are using it only for SMP init */ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |