[tip:core/rcu] memory-barriers: Retain barrier() in fold-to-zero example

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  efdcd51a4d5bd355796b1a757ff0355bb09ed394
Gitweb:     http://git.kernel.org/tip/efdcd51a4d5bd355796b1a757ff0355bb09ed394
Author:     Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
AuthorDate: Mon, 4 Aug 2014 11:49:34 -0700
Committer:  Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
CommitDate: Sun, 7 Sep 2014 16:15:52 -0700

memory-barriers: Retain barrier() in fold-to-zero example

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@xxxxxxxxxx>
Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>
---
 Documentation/memory-barriers.txt | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
index d67c508..600b45c 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -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. */
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux