summaryrefslogtreecommitdiffstats
path: root/kernel/Documentation/atomic_ops.txt
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/Documentation/atomic_ops.txt')
-rw-r--r--kernel/Documentation/atomic_ops.txt8
1 files changed, 7 insertions, 1 deletions
diff --git a/kernel/Documentation/atomic_ops.txt b/kernel/Documentation/atomic_ops.txt
index dab6da338..c9d1cacb4 100644
--- a/kernel/Documentation/atomic_ops.txt
+++ b/kernel/Documentation/atomic_ops.txt
@@ -266,7 +266,9 @@ with the given old and new values. Like all atomic_xxx operations,
atomic_cmpxchg will only satisfy its atomicity semantics as long as all
other accesses of *v are performed through atomic_xxx operations.
-atomic_cmpxchg must provide explicit memory barriers around the operation.
+atomic_cmpxchg must provide explicit memory barriers around the operation,
+although if the comparison fails then no memory ordering guarantees are
+required.
The semantics for atomic_cmpxchg are the same as those defined for 'cas'
below.
@@ -540,6 +542,10 @@ The routines xchg() and cmpxchg() must provide the same exact
memory-barrier semantics as the atomic and bit operations returning
values.
+Note: If someone wants to use xchg(), cmpxchg() and their variants,
+linux/atomic.h should be included rather than asm/cmpxchg.h, unless
+the code is in arch/* and can take care of itself.
+
Spinlocks and rwlocks have memory barrier expectations as well.
The rule to follow is simple: