atomic: add atomic_inc_not_zero_hint()
authorEric Dumazet <>
Thu, 11 Nov 2010 22:05:08 +0000 (14:05 -0800)
committerLinus Torvalds <>
Fri, 12 Nov 2010 15:55:30 +0000 (07:55 -0800)
atomic: add atomic_inc_not_zero_hint()

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

[ coding-style fixes]
Signed-off-by: Eric Dumazet <>
Cc: Christoph Lameter <>
Cc: Ingo Molnar <>
Cc: Andi Kleen <>
Cc: Arnaldo Carvalho de Melo <>
Cc: David Miller <>
Cc: "Paul E. McKenney" <>
Cc: Nick Piggin <>
Reviewed-by: "Paul E. McKenney" <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
include/linux/atomic.h [new file with mode: 0644]