Thread (152 messages) 152 messages, 13 authors, 2016-04-14

Re: [v3,11/41] mips: reuse asm-generic/barrier.h

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: 2016-01-18 08:22:36
Also in: linux-arch, linux-arm-kernel, linux-mips, linux-s390, linux-um, linuxppc-dev, lkml, sparclinux

Paul E. McKenney [off-list ref] wrote:
You could use SYNC_ACQUIRE() to implement read_barrier_depends() and
smp_read_barrier_depends(), but SYNC_RMB probably does not suffice.
The reason for this is that smp_read_barrier_depends() must order the
pointer load against any subsequent read or write through a dereference
of that pointer.  For example:

       p = READ_ONCE(gp);
       smp_rmb();
       r1 = p->a; /* ordered by smp_rmb(). */
       p->b = 42; /* NOT ordered by smp_rmb(), BUG!!! */
       r2 = x; /* ordered by smp_rmb(), but doesn't need to be. */

In contrast:

       p = READ_ONCE(gp);
       smp_read_barrier_depends();
       r1 = p->a; /* ordered by smp_read_barrier_depends(). */
       p->b = 42; /* ordered by smp_read_barrier_depends(). */
       r2 = x; /* not ordered by smp_read_barrier_depends(), which is OK. */

Again, if your hardware maintains local ordering for address
and data dependencies, you can have read_barrier_depends() and
smp_read_barrier_depends() be no-ops like they are for most
architectures.

Does that help?
This is crazy! smp_rmb started out being strictly stronger than
smp_read_barrier_depends, when did this stop being the case?
-- 
Email: Herbert Xu [off-list ref]
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help