[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44L0.1404181409300.1115-100000@iolanthe.rowland.org>
Date: Fri, 18 Apr 2014 14:16:40 -0400 (EDT)
From: Alan Stern <stern@...land.harvard.edu>
To: Oliver Neukum <oneukum@...e.de>
cc: linux-kernel@...r.kernel.org
Subject: Re: question on read_barrier_depends
On Fri, 18 Apr 2014, Oliver Neukum wrote:
> On Thu, 2014-04-17 at 11:50 -0400, Alan Stern wrote:
> > On Thu, 17 Apr 2014, Oliver Neukum wrote:
> >
> > > On Wed, 2014-04-16 at 11:26 -0400, Alan Stern wrote:
> > >
> > > > In addition, the following code in kfifo_get() does this:
> > > >
> > > > *(typeof(__tmp->type))__val = \
> > > > (__is_kfifo_ptr(__tmp) ? \
> > > > ((typeof(__tmp->type))__kfifo->data) : \
> > > > (__tmp->buf) \
> > > > )[__kfifo->out & __tmp->kfifo.mask]; \
> > > > smp_wmb(); \
> > > > __kfifo->out++; \
> > > >
> > > > It looks like the smp_wmb() should really be smp_mb(), because it
> > > > separates the _read_ for val from the _write_ of kfifo->out.
> > >
> > > But where is kfifo->out read at all?
> >
> > It is read in kfifo_put(), inside the call to kfifo_is_full() ->
> > kfifo_len().
>
> I had overlooked that. In that case kfifo_put() also needs
> smp_read_barrier_depends()
I don't think so.
kfifo_put() uses the read of kfifo->out to determine whether to perform
the store; i.e., it won't store the data if the kfifo is already full.
No architectures do speculative writes, so the data can never get
stored before kfifo->out is read, even without any memory barriers.
smp_read_barrier_depends() is meant to prevent speculative _reads_, or
any similar mechanism.
Alan Stern
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists