Re: [PATCH 1/5] smp_mb__{before,after}_atomic(): Update Documentation

From: Will Deacon
Date: Fri Nov 01 2019 - 12:49:55 EST


Hi Manfred,

On Sun, Oct 20, 2019 at 02:33:01PM +0200, Manfred Spraul wrote:
> 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.

[...]

> Documentation/memory-barriers.txt | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
> index 1adbb8a371c7..fe43f4b30907 100644
> --- a/Documentation/memory-barriers.txt
> +++ b/Documentation/memory-barriers.txt
> @@ -1873,12 +1873,16 @@ There are some more advanced barrier functions:
> (*) smp_mb__before_atomic();
> (*) smp_mb__after_atomic();
>
> - These are for use with atomic (such as add, subtract, increment and
> - decrement) functions that don't return a value, especially when used for
> - reference counting. These functions do not imply memory barriers.
> -
> - These are also used for atomic bitop functions that do not return a
> - value (such as set_bit and clear_bit).
> + These are for use with atomic RMW functions that do not imply memory
> + barriers, but where the code needs a memory barrier. Examples for atomic
> + RMW functions that do not imply are memory barrier are e.g. add,

typo: "are memory barrier"

> + subtract, (failed) conditional operations, _relaxed functions,
> + but not atomic_read or atomic_set. A common example where a memory
> + 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).

Although I think this is correct, I really think we should instead refer to
Documentation/atomic_t.txt and get rid of this out of memory-barriers.txt
entirely. It's just duplication and is out of date.

Will