aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/atomic_ops.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/atomic_ops.txt')
-rw-r--r--Documentation/atomic_ops.txt31
1 files changed, 12 insertions, 19 deletions
diff --git a/Documentation/atomic_ops.txt b/Documentation/atomic_ops.txt
index d9ca5be9b471..68542fe13b85 100644
--- a/Documentation/atomic_ops.txt
+++ b/Documentation/atomic_ops.txt
@@ -285,15 +285,13 @@ If a caller requires memory barrier semantics around an atomic_t
285operation which does not return a value, a set of interfaces are 285operation which does not return a value, a set of interfaces are
286defined which accomplish this: 286defined which accomplish this:
287 287
288 void smp_mb__before_atomic_dec(void); 288 void smp_mb__before_atomic(void);
289 void smp_mb__after_atomic_dec(void); 289 void smp_mb__after_atomic(void);
290 void smp_mb__before_atomic_inc(void);
291 void smp_mb__after_atomic_inc(void);
292 290
293For example, smp_mb__before_atomic_dec() can be used like so: 291For example, smp_mb__before_atomic() can be used like so:
294 292
295 obj->dead = 1; 293 obj->dead = 1;
296 smp_mb__before_atomic_dec(); 294 smp_mb__before_atomic();
297 atomic_dec(&obj->ref_count); 295 atomic_dec(&obj->ref_count);
298 296
299It makes sure that all memory operations preceding the atomic_dec() 297It makes sure that all memory operations preceding the atomic_dec()
@@ -302,15 +300,10 @@ operation. In the above example, it guarantees that the assignment of
302"1" to obj->dead will be globally visible to other cpus before the 300"1" to obj->dead will be globally visible to other cpus before the
303atomic counter decrement. 301atomic counter decrement.
304 302
305Without the explicit smp_mb__before_atomic_dec() call, the 303Without the explicit smp_mb__before_atomic() call, the
306implementation could legally allow the atomic counter update visible 304implementation could legally allow the atomic counter update visible
307to other cpus before the "obj->dead = 1;" assignment. 305to other cpus before the "obj->dead = 1;" assignment.
308 306
309The other three interfaces listed are used to provide explicit
310ordering with respect to memory operations after an atomic_dec() call
311(smp_mb__after_atomic_dec()) and around atomic_inc() calls
312(smp_mb__{before,after}_atomic_inc()).
313
314A missing memory barrier in the cases where they are required by the 307A missing memory barrier in the cases where they are required by the
315atomic_t implementation above can have disastrous results. Here is 308atomic_t implementation above can have disastrous results. Here is
316an example, which follows a pattern occurring frequently in the Linux 309an example, which follows a pattern occurring frequently in the Linux
@@ -487,12 +480,12 @@ Finally there is the basic operation:
487Which returns a boolean indicating if bit "nr" is set in the bitmask 480Which returns a boolean indicating if bit "nr" is set in the bitmask
488pointed to by "addr". 481pointed to by "addr".
489 482
490If explicit memory barriers are required around clear_bit() (which 483If explicit memory barriers are required around {set,clear}_bit() (which do
491does not return a value, and thus does not need to provide memory 484not return a value, and thus does not need to provide memory barrier
492barrier semantics), two interfaces are provided: 485semantics), two interfaces are provided:
493 486
494 void smp_mb__before_clear_bit(void); 487 void smp_mb__before_atomic(void);
495 void smp_mb__after_clear_bit(void); 488 void smp_mb__after_atomic(void);
496 489
497They are used as follows, and are akin to their atomic_t operation 490They are used as follows, and are akin to their atomic_t operation
498brothers: 491brothers:
@@ -500,13 +493,13 @@ brothers:
500 /* All memory operations before this call will 493 /* All memory operations before this call will
501 * be globally visible before the clear_bit(). 494 * be globally visible before the clear_bit().
502 */ 495 */
503 smp_mb__before_clear_bit(); 496 smp_mb__before_atomic();
504 clear_bit( ... ); 497 clear_bit( ... );
505 498
506 /* The clear_bit() will be visible before all 499 /* The clear_bit() will be visible before all
507 * subsequent memory operations. 500 * subsequent memory operations.
508 */ 501 */
509 smp_mb__after_clear_bit(); 502 smp_mb__after_atomic();
510 503
511There are two special bitops with lock barrier semantics (acquire/release, 504There are two special bitops with lock barrier semantics (acquire/release,
512same as spinlocks). These operate in the same way as their non-_lock/unlock 505same as spinlocks). These operate in the same way as their non-_lock/unlock