]> git.karo-electronics.de Git - linux-beck.git/commitdiff
doc: Fix memory-barrier control-dependency example
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Tue, 2 Jul 2013 22:24:09 +0000 (15:24 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Tue, 20 Aug 2013 04:39:42 +0000 (21:39 -0700)
Each control-dependency example needs its barriers between the "if"
condition and the body of the "if" because a control dependency is
a dependency induced by a branch.  This commit makes the needed
adjustment.

Reported-by: Yongming Shen <symingz@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Documentation/memory-barriers.txt

index fa5d8a9ae2051184ddba6ce3d1dd769414d2e59f..c8c42e64e953b4cd47d23da125ac5e057d1c158d 100644 (file)
@@ -531,9 +531,10 @@ dependency barrier to make it work correctly.  Consider the following bit of
 code:
 
        q = &a;
-       if (p)
+       if (p) {
+               <data dependency barrier>
                q = &b;
-       <data dependency barrier>
+       }
        x = *q;
 
 This will not have the desired effect because there is no actual data
@@ -542,9 +543,10 @@ attempting to predict the outcome in advance.  In such a case what's actually
 required is:
 
        q = &a;
-       if (p)
+       if (p) {
+               <read barrier>
                q = &b;
-       <read barrier>
+       }
        x = *q;