Re: posix timer freeze after some random time, under pthread create/destroy load
From: Frederic Weisbecker
Date: Fri Nov 22 2024 - 06:05:58 EST
Le Fri, Nov 22, 2024 at 09:24:07AM +0100, Oleg Nesterov a écrit :
> On 11/21, Frederic Weisbecker wrote:
> >
> > I think this started with commit:
> >
> > bcb7ee79029d (posix-timers: Prefer delivery of signals to the current thread)
> >
> > The problem is that if the current task is exiting and has already been reaped,
> > its sighand pointer isn't there anymore.
>
> Thanks...
>
> This can only happen if the exiting task has already passed exit_notify() which
> sets exit_state. So I'd suggest to check current->exit_state instead of PF_EXITING
> in the patch below.
>
> Oleg.
Right, I don't mind either way, though if it's past PF_EXITING,
complete_signal() -> wants_signal() will defer to another thread anyway, right?
Due to retarget_shared_pending() being called after the flag being set...
Thanks.
>
> > And so the signal is ignored even
> > though it should be queued to and handled by the thread group that has other
> > live threads to take care of it.
> >
> > Can you test the following patch? I'm cooking another patch with changelog for
> > upstream that has seen recent changes in this area.
> >
> > diff --git a/kernel/signal.c b/kernel/signal.c
> > index 8f6330f0e9ca..4cadee618d4b 100644
> > --- a/kernel/signal.c
> > +++ b/kernel/signal.c
> > @@ -1984,7 +1984,8 @@ int send_sigqueue(struct sigqueue *q, struct pid *pid, enum pid_type type)
> > t = pid_task(pid, type);
> > if (!t)
> > goto ret;
> > - if (type != PIDTYPE_PID && same_thread_group(t, current))
> > + if (type != PIDTYPE_PID && same_thread_group(t, current) &&
> > + !(current->flags & PF_EXITING))
> > t = current;
> > if (!likely(lock_task_sighand(t, &flags)))
> > goto ret;
> >
> >
>