aboutsummaryrefslogtreecommitdiff
path: root/include/linux/atomic.h
AgeCommit message (Collapse)AuthorFilesLines
2014-08-13locking: Remove deprecated smp_mb__() barriersPeter Zijlstra1-36/+0
Its been a while and there are no in-tree users left, so remove the deprecated barriers. Signed-off-by: Peter Zijlstra <[email protected]> Cc: Chen, Gong <[email protected]> Cc: Jacob Pan <[email protected]> Cc: Joe Perches <[email protected]> Cc: John Sullivan <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Srinivas Pandruvada <[email protected]> Cc: Theodore Ts'o <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2014-04-18arch: Prepare for smp_mb__{before,after}_atomic()Peter Zijlstra1-0/+36
Since the smp_mb__{before,after}*() ops are fundamentally dependent on how an arch can implement atomics it doesn't make sense to have 3 variants of them. They must all be the same. Furthermore, the 3 variants suggest they're only valid for those 3 atomic ops, while we have many more where they could be applied. So move away from smp_mb__{before,after}_{atomic,clear}_{dec,inc,bit}() and reduce the interface to just the two: smp_mb__{before,after}_atomic(). This patch prepares the way by introducing default implementations in asm-generic/barrier.h that default to a full barrier and providing __deprecated inlines for the previous 6 barriers if they're not provided by the arch. This should allow for a mostly painless transition (lots of deprecated warns in the interim). Signed-off-by: Peter Zijlstra <[email protected]> Acked-by: Paul E. McKenney <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Cc: Arnd Bergmann <[email protected]> Cc: "Chen, Gong" <[email protected]> Cc: John Sullivan <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Mauro Carvalho Chehab <[email protected]> Cc: Srinivas Pandruvada <[email protected]> Cc: "Theodore Ts'o" <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]>
2012-10-09atomic: implement generic atomic_dec_if_positive()Shaohua Li1-0/+25
The x86 implementation of atomic_dec_if_positive is quite generic, so make it available to all architectures. This is needed for "swap: add a simple detector for inappropriate swapin readahead". [[email protected]: do the "#define foo foo" trick in the conventional manner] Signed-off-by: Shaohua Li <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Michal Simek <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2012-03-07atomic: Allow atomic_inc_not_zero to be overriddenAnton Blanchard1-0/+2
We want to implement a ppc64 specific version of atomic_inc_not_zero so wrap it in an ifdef to allow it to be overridden. Signed-off-by: Anton Blanchard <[email protected]> Acked-by: Mike Frysinger <[email protected]> Signed-off-by: Benjamin Herrenschmidt <[email protected]>
2011-07-26atomic: Update comments in atomic.hArun Sharma1-0/+1
This clarifies the differences between <linux/atomic.h> and <asm-generic/atomic.h> Signed-off-by: Arun Sharma <[email protected]> Suggested-by: Mike Frysinger <[email protected]> Cc: Eric Dumazet <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: David Miller <[email protected]> Acked-by: Mike Frysinger <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-07-26atomic: cleanup asm-generic atomic*.h inclusionArun Sharma1-0/+4
After changing all consumers of atomics to include <linux/atomic.h>, we ran into some compile time errors due to this dependency chain: linux/atomic.h -> asm/atomic.h -> asm-generic/atomic-long.h where atomic-long.h could use funcs defined later in linux/atomic.h without a prototype. This patches moves the code that includes asm-generic/atomic*.h to linux/atomic.h. Archs that need <asm-generic/atomic64.h> need to select CONFIG_GENERIC_ATOMIC64 from now on (some of them used to include it unconditionally). Compile tested on i386 and x86_64 with allnoconfig. Signed-off-by: Arun Sharma <[email protected]> Cc: Eric Dumazet <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: David Miller <[email protected]> Acked-by: Mike Frysinger <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-07-26atomic: move atomic_add_unless to generic codeArun Sharma1-0/+14
This is in preparation for more generic atomic primitives based on __atomic_add_unless. Signed-off-by: Arun Sharma <[email protected]> Signed-off-by: Hans-Christian Egtvedt <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: David Miller <[email protected]> Acked-by: Mike Frysinger <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-07-26atomic: use <linux/atomic.h>Arun Sharma1-0/+9
This allows us to move duplicated code in <asm/atomic.h> (atomic_inc_not_zero() for now) to <linux/atomic.h> Signed-off-by: Arun Sharma <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: David Miller <[email protected]> Cc: Eric Dumazet <[email protected]> Acked-by: Mike Frysinger <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2011-07-20lockless get_write_access/deny_write_accessAl Viro1-0/+26
new helpers: atomic_inc_unless_negative()/atomic_dec_unless_positive() Signed-off-by: Al Viro <[email protected]>
2011-05-28atomic: Add atomic_or()Paul E. McKenney1-0/+13
An atomic_or() function is needed by TREE_RCU to avoid deadlock, so add a generic version. Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2010-11-12atomic: add atomic_inc_not_zero_hint()Eric Dumazet1-0/+37
Followup of perf tools session in Netfilter WorkShop 2010 In the network stack we make high usage of atomic_inc_not_zero() in contexts we know the probable value of atomic before increment (2 for udp sockets for example) Using a special version of atomic_inc_not_zero() giving this hint can help processor to use less bus transactions. On x86 (MESI protocol) for example, this avoids entering Shared state, because "lock cmpxchg" issues an RFO (Read For Ownership) akpm: Adds a new include/linux/atomic.h. This means that new code should henceforth include linux/atomic.h and not asm/atomic.h. The presence of include/linux/atomic.h will in fact cause checkpatch.pl to warn about use of asm/atomic.h. The new include/linux/atomic.h becomes the place where arch-neutral atomic_t code should be placed. [[email protected]: coding-style fixes] Signed-off-by: Eric Dumazet <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: David Miller <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: Nick Piggin <[email protected]> Reviewed-by: "Paul E. McKenney" <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>