[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YTO2yrr3z45XtGWt@zeniv-ca.linux.org.uk>
Date: Sat, 4 Sep 2021 18:11:22 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [possible bug] missed wakeup in do_sigtimedwait()?
On Sat, Sep 04, 2021 at 10:12:09AM -0700, Linus Torvalds wrote:
> On Sat, Sep 4, 2021 at 9:59 AM Linus Torvalds
> <torvalds@...ux-foundation.org> wrote:
> >
> > I agree, that seems like a bug, and your fix seems the trivially correct thing.
>
> Oh, never mind. Signals are special.
>
> Why?
>
> Because TASK_INTERRUPTIBLE is special, and schedule() will check for
> "am I trying to sleep while a signal is pending" and will never
> actually sleep.
>
> So you can't have missed wakeups from signals, because this sequence
> is perfectly ok, by design:
>
> - signal comes in and is pending
>
> - we set TASK_INTERRUPTIBLE
>
> - we are thinking about something *entirely* different, like looking
> at a pipe being emty
>
> - we schedule()
>
> and the pending signal will just mean that we never go to sleep.
>
> It's designed that way exactly so that people who have interruptible
> sleeps don't need to think about signals at all - they can concentrate
> on doing their own thing, and then do the "signal_pending()" check at
> any point without caring.
Thanks. AFAICS, it's this logics in __schedule():
if (signal_pending_state(prev_state, prev)) {
WRITE_ONCE(prev->__state, TASK_RUNNING);
IOW, TASK_INTERRUPTIBLE with signal_pending() or TASK_WAKEKILL with
pending SIGKILL. OK...
Powered by blists - more mailing lists