[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20090211211452.GA16883@redhat.com>
Date: Wed, 11 Feb 2009 22:14:52 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: "Eric W. Biederman" <ebiederm@...ssion.com>,
"Metzger, Markus T" <markus.t.metzger@...el.com>,
Roland McGrath <roland@...hat.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/4] reparent/untrace: do nothing if no childs/tracees
On 02/11, Oleg Nesterov wrote:
>
> However, forget_original_parent() has another problem. We can race with
> another thread which has already picked us for reparenting before we set
> PF_EXITING, so this patch also checks thread_group_empty().
>
> It is possible to be more clever, we can take tasklist for reading, or
> ensure that ->thread_group.prev is not PF_EXITING, but this is nasty.
> Perhaps even this optimization is too ugly.
Or, perhaps we can do:
static void forget_original_parent(struct task_struct *father)
{
struct task_struct *p, *n, *reaper;
LIST_HEAD(dead_childs);
if (list_empty(&father->children))
return;
write_lock_irq(&tasklist_lock);
again:
reaper = find_new_reaper(father);
list_for_each_entry_safe(p, n, &father->children, sibling) {
p->real_parent = reaper;
if (p->parent == father) {
BUG_ON(p->ptrace);
p->parent = p->real_parent;
}
reparent_thread(father, p, &dead_childs);
}
smp_mb(); /* do_exit() does mb() after exit_signals() */
if (unlikely(reaper->flags & PF_EXITING)) {
father = reaper;
goto again;
}
write_unlock_irq(&tasklist_lock);
BUG_ON(!list_empty(&father->children));
list_for_each_entry_safe(p, n, &dead_childs, sibling) {
list_del_init(&p->sibling);
release_task(p);
}
}
but this needs a fat comment at least. I am not sure this worth the trouble.
Oleg.
--
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