diff options
Diffstat (limited to 'Documentation/atomic_ops.txt')
-rw-r--r-- | Documentation/atomic_ops.txt | 31 |
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 | |||
285 | operation which does not return a value, a set of interfaces are | 285 | operation which does not return a value, a set of interfaces are |
286 | defined which accomplish this: | 286 | defined 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 | ||
293 | For example, smp_mb__before_atomic_dec() can be used like so: | 291 | For 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 | ||
299 | It makes sure that all memory operations preceding the atomic_dec() | 297 | It 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 |
303 | atomic counter decrement. | 301 | atomic counter decrement. |
304 | 302 | ||
305 | Without the explicit smp_mb__before_atomic_dec() call, the | 303 | Without the explicit smp_mb__before_atomic() call, the |
306 | implementation could legally allow the atomic counter update visible | 304 | implementation could legally allow the atomic counter update visible |
307 | to other cpus before the "obj->dead = 1;" assignment. | 305 | to other cpus before the "obj->dead = 1;" assignment. |
308 | 306 | ||
309 | The other three interfaces listed are used to provide explicit | ||
310 | ordering 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 | |||
314 | A missing memory barrier in the cases where they are required by the | 307 | A missing memory barrier in the cases where they are required by the |
315 | atomic_t implementation above can have disastrous results. Here is | 308 | atomic_t implementation above can have disastrous results. Here is |
316 | an example, which follows a pattern occurring frequently in the Linux | 309 | an example, which follows a pattern occurring frequently in the Linux |
@@ -487,12 +480,12 @@ Finally there is the basic operation: | |||
487 | Which returns a boolean indicating if bit "nr" is set in the bitmask | 480 | Which returns a boolean indicating if bit "nr" is set in the bitmask |
488 | pointed to by "addr". | 481 | pointed to by "addr". |
489 | 482 | ||
490 | If explicit memory barriers are required around clear_bit() (which | 483 | If explicit memory barriers are required around {set,clear}_bit() (which do |
491 | does not return a value, and thus does not need to provide memory | 484 | not return a value, and thus does not need to provide memory barrier |
492 | barrier semantics), two interfaces are provided: | 485 | semantics), 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 | ||
497 | They are used as follows, and are akin to their atomic_t operation | 490 | They are used as follows, and are akin to their atomic_t operation |
498 | brothers: | 491 | brothers: |
@@ -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 | ||
511 | There are two special bitops with lock barrier semantics (acquire/release, | 504 | There are two special bitops with lock barrier semantics (acquire/release, |
512 | same as spinlocks). These operate in the same way as their non-_lock/unlock | 505 | same as spinlocks). These operate in the same way as their non-_lock/unlock |