linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Eric Wong <normalperson@yhbt.net>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [RFC] pipe: prevent compiler reordering in pipe_poll
Date: Sat, 25 Aug 2018 00:05:49 +0100	[thread overview]
Message-ID: <20180824230549.GP6515@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20180824225431.tpaxuck7idgnj3b7@dcvr>

On Fri, Aug 24, 2018 at 10:54:31PM +0000, Eric Wong wrote:
> The pipe_poll function does not use locks, and adding an entry
> to the waitqueue is not guaranteed to happen before pipe->nrbufs
> (or other fields) are read, leading to missed wakeups.
> 
> Looking at Ruby CI build logs and backtraces, I've noticed
> occasional instances where processes are stuck in select(2) or
> ppoll(2) with a pipe.
> 
> I don't have access to the systems where this is happening to
> test/reproduce the problem, and haven't been able to reproduce
> it locally on less-powerful hardware, either.  However, it seems
> like a problem based on similar comments in
> fs/eventfd.c::eventfd_poll made by Paolo.

You are misinterpreting those comments.  That load *can't* migrate
to anything earlier than taking queue lock, since that acts as
an acquire barrier.  READ_ONCE in eventfd_poll() is not to prevent
compiler reordering - it's to prevent insane compiler doing multiple
loads on possibly changing variable (ctx->count there).

  reply	other threads:[~2018-08-25  2:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-24 22:54 [RFC] pipe: prevent compiler reordering in pipe_poll Eric Wong
2018-08-24 23:05 ` Al Viro [this message]
2018-09-10  8:55 ` Paolo Bonzini

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=20180824230549.GP6515@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=normalperson@yhbt.net \
    --cc=pbonzini@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;
as well as URLs for NNTP newsgroup(s).