path: root/Documentation/atomic_bitops.txt
diff options
authorWill Deacon <>2018-02-13 13:30:19 +0000
committerIngo Molnar <>2018-02-13 14:55:53 +0100
commit61e02392d3c7ecac1f91c0a90a8043d67e081846 (patch)
tree643df7dcf736a212690237f1b49ef108a2f096e6 /Documentation/atomic_bitops.txt
parent11dc13224c975efcec96647a4768a6f1bb7a19a8 (diff)
locking/atomic/bitops: Document and clarify ordering semantics for failed test_and_{}_bit()
A test_and_{}_bit() operation fails if the value of the bit is such that the modification does not take place. For example, if test_and_set_bit() returns 1. In these cases, follow the behaviour of cmpxchg and allow the operation to be unordered. This also applies to test_and_set_bit_lock() if the lock is found to be be taken already. Signed-off-by: Will Deacon <> Acked-by: Peter Zijlstra (Intel) <> Cc: Linus Torvalds <> Cc: Paul E. McKenney <> Cc: Thomas Gleixner <> Link: Signed-off-by: Ingo Molnar <>
Diffstat (limited to 'Documentation/atomic_bitops.txt')
1 files changed, 6 insertions, 1 deletions
diff --git a/Documentation/atomic_bitops.txt b/Documentation/atomic_bitops.txt
index 5550bfdcce5f..be70b32c95d9 100644
--- a/Documentation/atomic_bitops.txt
+++ b/Documentation/atomic_bitops.txt
@@ -58,7 +58,12 @@ Like with atomic_t, the rule of thumb is:
- RMW operations that have a return value are fully ordered.
-Except for test_and_set_bit_lock() which has ACQUIRE semantics and
+ - RMW operations that are conditional are unordered on FAILURE,
+ otherwise the above rules apply. In the case of test_and_{}_bit() operations,
+ if the bit in memory is unchanged by the operation then it is deemed to have
+ failed.
+Except for a successful test_and_set_bit_lock() which has ACQUIRE semantics and
clear_bit_unlock() which has RELEASE semantics.
Since a platform only has a single means of achieving atomic operations