diff options
author | Will Deacon <will.deacon@arm.com> | 2015-07-16 11:10:06 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-08-03 04:57:09 -0400 |
commit | ed2de9f74ecbbf3063d29b2334e7b455d7f35189 (patch) | |
tree | b72f333309835d9b23c695d2921c965627746c69 | |
parent | 0b792bf519e68108d577fcec815ab50913787012 (diff) |
locking/Documentation: Clarify failed cmpxchg() memory ordering semantics
A failed cmpxchg does not provide any memory ordering guarantees, a
property that is used to optimise the cmpxchg implementations on Alpha,
PowerPC and arm64.
This patch updates atomic_ops.txt and memory-barriers.txt to reflect
this.
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Douglas Hatch <doug.hatch@hp.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Scott J Norton <scott.norton@hp.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Waiman Long <waiman.long@hp.com>
Link: http://lkml.kernel.org/r/20150716151006.GH26390@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | Documentation/atomic_ops.txt | 4 | ||||
-rw-r--r-- | Documentation/memory-barriers.txt | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/Documentation/atomic_ops.txt b/Documentation/atomic_ops.txt index dab6da3382d9..b19fc34efdb1 100644 --- a/Documentation/atomic_ops.txt +++ b/Documentation/atomic_ops.txt | |||
@@ -266,7 +266,9 @@ with the given old and new values. Like all atomic_xxx operations, | |||
266 | atomic_cmpxchg will only satisfy its atomicity semantics as long as all | 266 | atomic_cmpxchg will only satisfy its atomicity semantics as long as all |
267 | other accesses of *v are performed through atomic_xxx operations. | 267 | other accesses of *v are performed through atomic_xxx operations. |
268 | 268 | ||
269 | atomic_cmpxchg must provide explicit memory barriers around the operation. | 269 | atomic_cmpxchg must provide explicit memory barriers around the operation, |
270 | although if the comparison fails then no memory ordering guarantees are | ||
271 | required. | ||
270 | 272 | ||
271 | The semantics for atomic_cmpxchg are the same as those defined for 'cas' | 273 | The semantics for atomic_cmpxchg are the same as those defined for 'cas' |
272 | below. | 274 | below. |
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt index 13feb697271f..18fc860df1be 100644 --- a/Documentation/memory-barriers.txt +++ b/Documentation/memory-barriers.txt | |||
@@ -2383,9 +2383,7 @@ about the state (old or new) implies an SMP-conditional general memory barrier | |||
2383 | explicit lock operations, described later). These include: | 2383 | explicit lock operations, described later). These include: |
2384 | 2384 | ||
2385 | xchg(); | 2385 | xchg(); |
2386 | cmpxchg(); | ||
2387 | atomic_xchg(); atomic_long_xchg(); | 2386 | atomic_xchg(); atomic_long_xchg(); |
2388 | atomic_cmpxchg(); atomic_long_cmpxchg(); | ||
2389 | atomic_inc_return(); atomic_long_inc_return(); | 2387 | atomic_inc_return(); atomic_long_inc_return(); |
2390 | atomic_dec_return(); atomic_long_dec_return(); | 2388 | atomic_dec_return(); atomic_long_dec_return(); |
2391 | atomic_add_return(); atomic_long_add_return(); | 2389 | atomic_add_return(); atomic_long_add_return(); |
@@ -2398,7 +2396,9 @@ explicit lock operations, described later). These include: | |||
2398 | test_and_clear_bit(); | 2396 | test_and_clear_bit(); |
2399 | test_and_change_bit(); | 2397 | test_and_change_bit(); |
2400 | 2398 | ||
2401 | /* when succeeds (returns 1) */ | 2399 | /* when succeeds */ |
2400 | cmpxchg(); | ||
2401 | atomic_cmpxchg(); atomic_long_cmpxchg(); | ||
2402 | atomic_add_unless(); atomic_long_add_unless(); | 2402 | atomic_add_unless(); atomic_long_add_unless(); |
2403 | 2403 | ||
2404 | These are used for such things as implementing ACQUIRE-class and RELEASE-class | 2404 | These are used for such things as implementing ACQUIRE-class and RELEASE-class |