Re: [PATCH] fix send_sigqueue() vs thread exit race

From: Thomas Gleixner
Date: Tue Aug 23 2005 - 13:29:41 EST


On Tue, 2005-08-23 at 20:17 +0400, Oleg Nesterov wrote:
> Thomas Gleixner wrote:
> > I still think the last patch I sent is still necessary.
>
> Thomas, you know that I like this change in __exit_{signal,sighand},
> but i think this change is dangerous, should go in a separate patch,
> and needs a lot of testing. But the decision is up to Ingo and Roland.

Maybe it makes more sense in context of Pauls RCU stuff.

> What do you think about this:
>
> int try_to_lock_this_beep_tasklist_lock(struct task_struct *group_leader)
> {
> while (unlikely(!read_trylock(&tasklist_lock))) {
> if (group_leader->flags & PF_EXITING) {
> smp_rmb();
> if (thread_group_empty(group_leader))
> return 0;
> }
> cpu_relax();
> }
>
> return 1;
> }
>
> No need to re-check after we got tasklist, the signal will be flushed.

Makes sense, though I'm not sure if its safe to call
thread_group_empty() without tasklist lock held. I might be in case of
PF_EXITING, but it needs a comment at least.

> I think it's better to move the locking into the posix_timer_event, btw.

Hmm, not sure. I've seen similar stuff in the AIO patches. I guess this
should be solved safe at one place rather than all around the kernel.

tglx



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/