The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Manfred Spraul <manfred@colorfullife.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, Roland McGrath <roland@redhat.com>
Subject: Re: [PATCH] Use ERESTARTNOHAND if poll() is interrupted by a signal
Date: Wed, 1 Aug 2007 01:08:17 +0400	[thread overview]
Message-ID: <20070731210817.GA97@tv-sign.ru> (raw)
In-Reply-To: <46AF9C2D.70808@colorfullife.com>

On 07/31, Manfred Spraul wrote:
>
> Mainline has the same problem: poll() returns to user space if it's 
> interrupted by SIGSTOP/SIGCONT.
> >I guess the consequences of the thing-which-this-fixes aren't huge, s I ca
> >queue this up for 2.6.24, after Oleg's
> >do_poll-return-eintr-when-signalled.patch?
> >
> >  
> Yes, please queue it: most/all linux versions show this behavior. 
> Additionally, poll() is usually called in a loop and a spurious wakeup 
> has no consequences.

... and so the current behaviour is more or less correct, even if not
optimal.

But this patch in fact adds a bug. We don't even need the "special"
signals like SIGSTOP/SIGCONT or freezer to hit this bug.

Suppose that sys_poll() was interrupted by a "normal" signal which
has a handler. It is quite possible that another thread can steal
this signal before us. Now, ERESTARTNOHAND means we restart sys_poll()
with the same (old) timeout, this means that sys_poll() does _not_
return when timeout expired (if no fds ready), and this is bug.

Also, the false signal_wake_up() is possible, and again, the spurious
-EINTR is better than restart with the same timeout.

What we need is ERESTART_RESTARTBLOCK, and restart_block.arg2 should
have the new timeout value, which takes the time we already slept
into account.

Oleg.


  reply	other threads:[~2007-07-31 21:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-29 17:05 [PATCH] Use ERESTARTNOHAND if poll() is interrupted by a signal Manfred Spraul
2007-07-30 23:35 ` Andrew Morton
2007-07-30 23:59   ` Chris Wright
2007-07-31  0:11   ` Oleg Nesterov
2007-07-31  0:18     ` Oleg Nesterov
2007-07-31 17:36       ` Chris Wright
2007-07-31 20:31   ` Manfred Spraul
2007-07-31 21:08     ` Oleg Nesterov [this message]
2007-08-04  6:39       ` [PATCH] Use ERESTART_RESTARTBLOCK if poll() is interrupted by a signal (was: Re: [PATCH] Use ERESTARTNOHAND if poll() is interrupted by a signal) Chris Wright
2007-08-04 11:07         ` Oleg Nesterov
2007-08-15 22:27           ` [PATCH take2] Use ERESTART_RESTARTBLOCK if poll() is interrupted by a signal Chris Wright
2007-08-16 15:51             ` Oleg Nesterov
2007-08-28  9:11   ` [PATCH] Use ERESTARTNOHAND " Roland McGrath
2007-07-30 23:56 ` Chris Wright

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=20070731210817.GA97@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=roland@redhat.com \
    /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