summaryrefslogtreecommitdiffstats
path: root/Documentation/memory-barriers.txt
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2014-03-13 14:00:35 -0400
committerIngo Molnar <mingo@kernel.org>2014-04-18 08:20:48 -0400
commit1b15611e1c30b37abe393d411c316cd659920bf5 (patch)
tree99992be63b630b8a64135f47e2f93f90db7cbab1 /Documentation/memory-barriers.txt
parent09a01c0ccb1837abb28afcfdd668fa0dfabed928 (diff)
arch,doc: Convert smp_mb__*()
Update the documentation to reflect the change of barrier primitives. Signed-off-by: Peter Zijlstra <peterz@infradead.org> Reviewed-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Acked-by: David Howells <dhowells@redhat.com> Link: http://lkml.kernel.org/n/tip-xslfehiga1twbk5uk94rij1e@git.kernel.org Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'Documentation/memory-barriers.txt')
-rw-r--r--Documentation/memory-barriers.txt42
1 files changed, 11 insertions, 31 deletions
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
index 556f951f8626..46412bded104 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -1583,20 +1583,21 @@ There are some more advanced barrier functions:
1583 insert anything more than a compiler barrier in a UP compilation. 1583 insert anything more than a compiler barrier in a UP compilation.
1584 1584
1585 1585
1586 (*) smp_mb__before_atomic_dec(); 1586 (*) smp_mb__before_atomic();
1587 (*) smp_mb__after_atomic_dec(); 1587 (*) smp_mb__after_atomic();
1588 (*) smp_mb__before_atomic_inc();
1589 (*) smp_mb__after_atomic_inc();
1590 1588
1591 These are for use with atomic add, subtract, increment and decrement 1589 These are for use with atomic (such as add, subtract, increment and
1592 functions that don't return a value, especially when used for reference 1590 decrement) functions that don't return a value, especially when used for
1593 counting. These functions do not imply memory barriers. 1591 reference counting. These functions do not imply memory barriers.
1592
1593 These are also used for atomic bitop functions that do not return a
1594 value (such as set_bit and clear_bit).
1594 1595
1595 As an example, consider a piece of code that marks an object as being dead 1596 As an example, consider a piece of code that marks an object as being dead
1596 and then decrements the object's reference count: 1597 and then decrements the object's reference count:
1597 1598
1598 obj->dead = 1; 1599 obj->dead = 1;
1599 smp_mb__before_atomic_dec(); 1600 smp_mb__before_atomic();
1600 atomic_dec(&obj->ref_count); 1601 atomic_dec(&obj->ref_count);
1601 1602
1602 This makes sure that the death mark on the object is perceived to be set 1603 This makes sure that the death mark on the object is perceived to be set
@@ -1606,27 +1607,6 @@ There are some more advanced barrier functions:
1606 operations" subsection for information on where to use these. 1607 operations" subsection for information on where to use these.
1607 1608
1608 1609
1609 (*) smp_mb__before_clear_bit(void);
1610 (*) smp_mb__after_clear_bit(void);
1611
1612 These are for use similar to the atomic inc/dec barriers. These are
1613 typically used for bitwise unlocking operations, so care must be taken as
1614 there are no implicit memory barriers here either.
1615
1616 Consider implementing an unlock operation of some nature by clearing a
1617 locking bit. The clear_bit() would then need to be barriered like this:
1618
1619 smp_mb__before_clear_bit();
1620 clear_bit( ... );
1621
1622 This prevents memory operations before the clear leaking to after it. See
1623 the subsection on "Locking Functions" with reference to RELEASE operation
1624 implications.
1625
1626 See Documentation/atomic_ops.txt for more information. See the "Atomic
1627 operations" subsection for information on where to use these.
1628
1629
1630MMIO WRITE BARRIER 1610MMIO WRITE BARRIER
1631------------------ 1611------------------
1632 1612
@@ -2283,11 +2263,11 @@ operations:
2283 change_bit(); 2263 change_bit();
2284 2264
2285With these the appropriate explicit memory barrier should be used if necessary 2265With these the appropriate explicit memory barrier should be used if necessary
2286(smp_mb__before_clear_bit() for instance). 2266(smp_mb__before_atomic() for instance).
2287 2267
2288 2268
2289The following also do _not_ imply memory barriers, and so may require explicit 2269The following also do _not_ imply memory barriers, and so may require explicit
2290memory barriers under some circumstances (smp_mb__before_atomic_dec() for 2270memory barriers under some circumstances (smp_mb__before_atomic() for
2291instance): 2271instance):
2292 2272
2293 atomic_add(); 2273 atomic_add();