* atomic_add_unless() and mb()
@ 2006-11-25 21:18 Oleg Nesterov
0 siblings, 0 replies; only message in thread
From: Oleg Nesterov @ 2006-11-25 21:18 UTC (permalink / raw)
To: David S. Miller, David Howells; +Cc: Alan Stern, Paul E. McKenney, linux-kernel
Both Documentation/memory-barriers.txt and Documentation/atomic_ops.txt state
that atomic_add_unless() implies smp_mb() on each side of the operation.
Is it true?
include/asm-most_of/atomic.h:
#define atomic_add_unless(v, a, u) \
({ \
int c, old; \
c = atomic_read(v); \
for (;;) { \
if (unlikely(c == (u))) \
break; \
old = atomic_cmpxchg((v), c, c + (a)); \
if (likely(old == c)) \
break; \
c = old; \
} \
c != (u); \
})
This looks like atomic_add_unless() implies mb() only if it returns 1.
Otherwise it could fail (return 0) before the first atomic_cmpxchg(),
but atomic_read() provides a compiler barrier only.
Could you clarify?
Oleg.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-11-25 21:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-25 21:18 atomic_add_unless() and mb() Oleg Nesterov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox