All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Xiao Guangrong <guangrong.xiao@gmail.com>,
	rostedt@goodmis.org, Lai Jiangshan <jiangshanlai@gmail.com>,
	stefani@seibold.net,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: Is read barrier missed in kfifo?
Date: Mon, 14 May 2018 06:25:41 -0700	[thread overview]
Message-ID: <20180514132541.GS26088@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180514065755.GM12217@hirez.programming.kicks-ass.net>

On Mon, May 14, 2018 at 08:57:55AM +0200, Peter Zijlstra wrote:
> On Fri, May 11, 2018 at 09:20:53AM -0700, Paul E. McKenney wrote:
> > On Fri, May 11, 2018 at 10:32:42AM +0200, Peter Zijlstra wrote:
> > > On Fri, May 11, 2018 at 03:25:18PM +0800, Xiao Guangrong wrote:
> > > > 
> > > > Hi,
> > > > 
> > > > Currently, there is no read barrier between reading the index
> > > > (kfifo.in) and fetching the real data from the fifo.
> > > > 
> > > > I am afraid that will cause the vfifo is observed as not empty
> > > > however the data is not actually ready for read. Right?
> > > 
> > > That code is decidedly dodgy indeed. I can only see smp_wmb() but no
> > > matching barriers at all -- therefore the code is almost certainly as
> > > good as not having any barriers at all.
> > > 
> > > I would suggest you try and convert the code to smp_store_release() and
> > > smp_load_acquire() while you're at it.
> > 
> > Isn't this one of the places where we rely on control dependencies?
> 
> Then it bloody well should have a comment. But at least one side of the
> fifo needs a read barrier I think. We can rely on a ctrl-dep on the
> write side, where we read the head/tail values, compute space and then
> conditionally allow writes to happen.
> 
> But on the read side it's all reads and ctrl-dep doesn't help anything.

Agreed, for a control depdendency to help, there does need to be a
control dependency.  ;-)

							Thanx, Paul

      reply	other threads:[~2018-05-14 13:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-11  7:25 Is read barrier missed in kfifo? Xiao Guangrong
2018-05-11  7:33 ` Stefani Seibold
2018-05-11  8:32 ` Peter Zijlstra
2018-05-11 16:20   ` Paul E. McKenney
2018-05-14  6:57     ` Peter Zijlstra
2018-05-14 13:25       ` Paul E. McKenney [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=20180514132541.GS26088@linux.vnet.ibm.com \
    --to=paulmck@linux.vnet.ibm.com \
    --cc=guangrong.xiao@gmail.com \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=stefani@seibold.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.