From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B211AC4332F for ; Sat, 4 Sep 2021 18:18:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FF8E60FDC for ; Sat, 4 Sep 2021 18:18:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237326AbhIDSM1 (ORCPT ); Sat, 4 Sep 2021 14:12:27 -0400 Received: from zeniv-ca.linux.org.uk ([142.44.231.140]:42652 "EHLO zeniv-ca.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232946AbhIDSMZ (ORCPT ); Sat, 4 Sep 2021 14:12:25 -0400 Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mMa8Q-0016cN-Q0; Sat, 04 Sep 2021 18:11:23 +0000 Date: Sat, 4 Sep 2021 18:11:22 +0000 From: Al Viro To: Linus Torvalds Cc: Linux Kernel Mailing List Subject: Re: [possible bug] missed wakeup in do_sigtimedwait()? Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 04, 2021 at 10:12:09AM -0700, Linus Torvalds wrote: > On Sat, Sep 4, 2021 at 9:59 AM Linus Torvalds > 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...