Commit 39323c64 authored by Manfred Spraul's avatar Manfred Spraul Committed by Linus Torvalds

smp_mb__{before,after}_atomic(): update Documentation

When adding the _{acquire|release|relaxed}() variants of some atomic
operations, it was forgotten to update Documentation/memory_barrier.txt:

smp_mb__{before,after}_atomic() is now intended for all RMW operations
that do not imply a memory barrier.

1)
	smp_mb__before_atomic();
	atomic_add();

2)
	smp_mb__before_atomic();
	atomic_xchg_relaxed();

3)
	smp_mb__before_atomic();
	atomic_fetch_add_relaxed();

Invalid would be:
	smp_mb__before_atomic();
	atomic_set();

In addition, the patch splits the long sentence into multiple shorter
sentences.

Link: http://lkml.kernel.org/r/20191020123305.14715-2-manfred@colorfullife.com
Fixes: 654672d4 ("locking/atomics: Add _{acquire|release|relaxed}() variants of some atomic operations")
Signed-off-by: default avatarManfred Spraul <manfred@colorfullife.com>
Acked-by: default avatarWaiman Long <longman@redhat.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: <1vier1@web.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 92917998
...@@ -1868,12 +1868,16 @@ There are some more advanced barrier functions: ...@@ -1868,12 +1868,16 @@ There are some more advanced barrier functions:
(*) smp_mb__before_atomic(); (*) smp_mb__before_atomic();
(*) smp_mb__after_atomic(); (*) smp_mb__after_atomic();
These are for use with atomic (such as add, subtract, increment and These are for use with atomic RMW functions that do not imply memory
decrement) functions that don't return a value, especially when used for barriers, but where the code needs a memory barrier. Examples for atomic
reference counting. These functions do not imply memory barriers. RMW functions that do not imply are memory barrier are e.g. add,
subtract, (failed) conditional operations, _relaxed functions,
These are also used for atomic bitop functions that do not return a but not atomic_read or atomic_set. A common example where a memory
value (such as set_bit and clear_bit). barrier may be required is when atomic ops are used for reference
counting.
These are also used for atomic RMW bitop functions that do not imply a
memory barrier (such as set_bit and clear_bit).
As an example, consider a piece of code that marks an object as being dead As an example, consider a piece of code that marks an object as being dead
and then decrements the object's reference count: and then decrements the object's reference count:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment