]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
memory-barriers: Retain barrier() in fold-to-zero example
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Mon, 4 Aug 2014 18:49:34 +0000 (11:49 -0700)
committerPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Sun, 7 Sep 2014 23:15:52 +0000 (16:15 -0700)
The transformation in the fold-to-zero example incorrectly omits the
barrier() directive.  This commit therefore adds it back in.

Reported-by: Pranith Kumar <pranith@gatech.edu>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Documentation/memory-barriers.txt

index d67c508eb660b1f83439180afa0885504abbea2a..600b45c6e2ad8cb4d808c5ca0ce7f75922b5db75 100644 (file)
@@ -679,12 +679,15 @@ equal to zero, in which case the compiler is within its rights to
 transform the above code into the following:
 
        q = ACCESS_ONCE(a);
+       barrier();
        ACCESS_ONCE(b) = p;
        do_something_else();
 
-This transformation loses the ordering between the load from variable 'a'
-and the store to variable 'b'.  If you are relying on this ordering, you
-should do something like the following:
+This transformation fails to require that the CPU respect the ordering
+between the load from variable 'a' and the store to variable 'b'.
+Yes, the barrier() is still there, but it affects only the compiler,
+not the CPU.  Therefore, if you are relying on this ordering, you should
+do something like the following:
 
        q = ACCESS_ONCE(a);
        BUILD_BUG_ON(MAX <= 1); /* Order load from a with store to b. */