Re: [PATCH] signals: work around random wakeups in sigsuspend()

From: Oleg Nesterov
Date: Wed Jan 27 2016 - 16:08:09 EST

On 01/27, Andrew Morton wrote:
> On Wed, 27 Jan 2016 17:41:54 +0100 Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> > IOW, signal_pending() is the "special" condition, you do not need to serialize
> > this check with task->state setting, exactly because schedule() knows about the
> > signals.
> So it's non-buggy because signal_pending() is special. But it *looks*
> buggy! And there's no comment there explaining why it looks buggy but
> isn't, so someone may later come along and "fix" it for us.

perhaps we can add a comment somewhere in sched.h to explain that a task can
never sleep with task->state == STATE if signal_pending_state(STATE) is true.

Every user of signal_pending() in the wait-event-like loop relies on this well-
known fact. Say, wait_event_interruptible() or __mutex_lock_common().

This is actually more about task->state, not about TIF_SIGPENDING imo.