linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Denys Vlasenko <dvlasenk@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] epoll_wait: fix EINTR leak
Date: Mon, 24 Jun 2013 20:39:31 +0200	[thread overview]
Message-ID: <20130624183931.GA4464@redhat.com> (raw)
In-Reply-To: <20130624170856.GA475@redhat.com>

On 06/24, Oleg Nesterov wrote:
>
> On 06/24, Denys Vlasenko wrote:
> >
> > Usage of EINTR is wrong.
>
> I agree, this is not nice. However "fix EINTR leak" doesn't look
> accurate, -EINTR is fine as an error code. Just the syscall should
> restart if possible.
>
> > --- a/fs/eventpoll.c
> > +++ b/fs/eventpoll.c
> > @@ -1598,7 +1598,7 @@ fetch_events:
> >  			if (ep_events_available(ep) || timed_out)
> >  				break;
> >  			if (signal_pending(current)) {
> > -				res = -EINTR;
> > +				res = -ERESTARTNOHAND;
>
> This and other similar changes do look right.
>
> Say, sys_epoll_wait(). With this patch it can sleep, then return
> ERESTARTNOHAND.
>
> And we restart it with the same timeout again. If you want to
> make it restartable, you need ERESTART_RESTARTBLOCK and
> do_restart_epoll_wait() which we do not have.
>
> See for example sys_poll() which implements this logic.

But, to avoid the confusion, please note that this change won't
make it restartable wrt SA_RESTART. But it will help PTRACE_ATTACH
or PTRACE_INTERRUPT or other "spurious" signal.

We simply can't do this because there is no way to update
"timeout" later if the task actually returns to user-mode.

Oleg.


      reply	other threads:[~2013-06-24 18:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-24 15:31 [PATCH] epoll_wait: fix EINTR leak Denys Vlasenko
2013-06-24 17:08 ` Oleg Nesterov
2013-06-24 18:39   ` Oleg Nesterov [this message]

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=20130624183931.GA4464@redhat.com \
    --to=oleg@redhat.com \
    --cc=dvlasenk@redhat.com \
    --cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).