linux/scripts/atomic/kerneldoc
Mark Rutland 6dfee110c6 locking/atomic: scripts: Clarify ordering of conditional atomics
Conditional atomic operations (e.g. cmpxchg()) only provide ordering
when the condition holds; when the condition does not hold, the location
is not modified and relaxed ordering is provided. Where ordering is
needed for failed conditional atomics, it is necessary to use
smp_mb__before_atomic() and/or smp_mb__after_atomic().

This is explained tersely in memory-barriers.txt, and is implied but not
explicitly stated in the kerneldoc comments for the conditional
operations. The lack of an explicit statement has lead to some off-list
queries about the ordering semantics of failing conditional operations,
so evidently this is confusing.

Update the kerneldoc comments to explicitly describe the lack of ordering
for failed conditional atomic operations.

For most conditional atomic operations, this is written as:

  | If (${condition}), atomically updates @v to (${new}) with ${desc_order} ordering.
  | Otherwise, @v is not modified and relaxed ordering is provided.

For the try_cmpxchg() operations, this is written as:

  | If (${condition}), atomically updates @v to @new with ${desc_order} ordering.
  | Otherwise, @v is not modified, @old is updated to the current value of @v,
  | and relaxed ordering is provided.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Nhat Pham <nphamcs@gmail.com>
Link: https://lore.kernel.org/r/20240209124010.2096198-1-mark.rutland@arm.com
2024-02-20 09:55:09 +01:00
..
add locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
add_negative locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
add_unless locking/atomic: scripts: Clarify ordering of conditional atomics 2024-02-20 09:55:09 +01:00
and locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
andnot locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
cmpxchg locking/atomic: scripts: Clarify ordering of conditional atomics 2024-02-20 09:55:09 +01:00
dec locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
dec_and_test locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
dec_if_positive locking/atomic: scripts: Clarify ordering of conditional atomics 2024-02-20 09:55:09 +01:00
dec_unless_positive locking/atomic: scripts: Clarify ordering of conditional atomics 2024-02-20 09:55:09 +01:00
inc locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
inc_and_test locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
inc_not_zero locking/atomic: scripts: Clarify ordering of conditional atomics 2024-02-20 09:55:09 +01:00
inc_unless_negative locking/atomic: scripts: Clarify ordering of conditional atomics 2024-02-20 09:55:09 +01:00
or locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
read locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
set locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
sub locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
sub_and_test locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
try_cmpxchg locking/atomic: scripts: Clarify ordering of conditional atomics 2024-02-20 09:55:09 +01:00
xchg locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00
xor locking/atomic: scripts: generate kerneldoc comments 2023-06-05 09:57:23 +02:00