From: Al Viro <viro@zeniv.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [possible bug] missed wakeup in do_sigtimedwait()?
Date: Sat, 4 Sep 2021 18:11:22 +0000 [thread overview]
Message-ID: <YTO2yrr3z45XtGWt@zeniv-ca.linux.org.uk> (raw)
In-Reply-To: <CAHk-=whx9iKutjLY6iRBHg2TTzSDXgrZ0-Uj5sUqhyQZZQ_yRQ@mail.gmail.com>
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@linux-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...
next prev parent reply other threads:[~2021-09-04 18:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-04 14:42 Al Viro
2021-09-04 16:59 ` Linus Torvalds
2021-09-04 17:12 ` Linus Torvalds
2021-09-04 18:11 ` Al Viro [this message]
2021-09-04 18:21 ` Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YTO2yrr3z45XtGWt@zeniv-ca.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®