linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Behaviour of smp_mb__{before,after}_spin* and acquire/release
@ 2015-01-13 16:33 Will Deacon
  2015-01-13 16:33 ` Will Deacon
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Will Deacon @ 2015-01-13 16:33 UTC (permalink / raw)
  To: paulmck, peterz; +Cc: torvalds, oleg, benh, linux-kernel, linux-arch

Hi Paul,

I started dusting off a series I've been working to implement a relaxed
atomic API in Linux (i.e. things like atomic_read(v, ACQUIRE)) but I'm
having trouble making sense of the ordering semantics we have in mainline
today:

  1. Does smp_mb__before_spinlock actually have to order prior loads
     against later loads and stores? Documentation/memory-barriers.txt
     says it does, but that doesn't match the comment (or implementation)
     in include/linux/spinlock.h

  2. Does smp_mb__after_unlock_lock order smp_store_release against
     smp_load_acquire? Again, Documentation/memory-barriers.txt puts
     these operations into the RELEASE and ACQUIRE classes respectively,
     but since smp_mb__after_unlock_lock is a NOP everywhere other than
     PowerPC, I don't think this is enforced by the current code. Most
     architectures follow the pattern used by asm-generic/barrier.h:

       release: smp_mb(); STORE
       acquire: LOAD; smp_mb();

     which doesn't provide any release -> acquire ordering afaict.

My plan for the atomics was to add acquire, release, acquire + release
and unordered variants, where the acquire/release semantics would
actually be sequentially consistent. That allows us to implement the
existing atomics easily in terms of the new API, but it's different
to what we're doing for the smp_load_acquire and smp_store_release
functions above.

Cheers,

Will

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-01-23 21:21 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-13 16:33 Behaviour of smp_mb__{before,after}_spin* and acquire/release Will Deacon
2015-01-13 16:33 ` Will Deacon
2015-01-13 18:45 ` Oleg Nesterov
2015-01-13 18:45   ` Oleg Nesterov
2015-01-14 11:31   ` Will Deacon
2015-01-20  3:40     ` Paul E. McKenney
2015-01-20 10:43       ` Will Deacon
2015-01-20 10:43         ` Will Deacon
2015-01-20  9:34 ` Peter Zijlstra
2015-01-20 10:38   ` Will Deacon
2015-01-20 21:35   ` Paul E. McKenney
2015-01-21 13:56     ` Will Deacon
2015-01-23 14:08     ` Will Deacon
2015-01-23 14:08       ` Will Deacon
2015-01-23 21:21       ` Paul E. McKenney

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).