mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
atomic: Implement atomic_read_ctrl()
Provide atomic_read_ctrl() to mirror READ_ONCE_CTRL(), such that we can more conveniently use atomics in control dependencies. Since we can assume atomic_read() implies a READ_ONCE(), we must only emit an extra smp_read_barrier_depends() in order to upgrade to READ_ONCE_CTRL() semantics. Requested-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Will Deacon <will.deacon@arm.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Cc: oleg@redhat.com Link: http://lkml.kernel.org/r/20150918115637.GM3604@twins.programming.kicks-ass.net Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
62e8a3258b
commit
e3e72ab80a
3 changed files with 29 additions and 9 deletions
|
@ -4,6 +4,15 @@
|
|||
#include <asm/atomic.h>
|
||||
#include <asm/barrier.h>
|
||||
|
||||
#ifndef atomic_read_ctrl
|
||||
static inline int atomic_read_ctrl(const atomic_t *v)
|
||||
{
|
||||
int val = atomic_read(v);
|
||||
smp_read_barrier_depends(); /* Enforce control dependency. */
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Relaxed variants of xchg, cmpxchg and some atomic operations.
|
||||
*
|
||||
|
@ -455,6 +464,15 @@ static inline int atomic_dec_if_positive(atomic_t *v)
|
|||
#include <asm-generic/atomic64.h>
|
||||
#endif
|
||||
|
||||
#ifndef atomic64_read_ctrl
|
||||
static inline long long atomic64_read_ctrl(const atomic64_t *v)
|
||||
{
|
||||
long long val = atomic64_read(v);
|
||||
smp_read_barrier_depends(); /* Enforce control dependency. */
|
||||
return val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef atomic64_andnot
|
||||
static inline void atomic64_andnot(long long i, atomic64_t *v)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue