diff options
author | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2013-07-02 18:24:09 -0400 |
---|---|---|
committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2013-08-20 00:39:42 -0400 |
commit | 45c8a36a5519960638a4f331839bb99c1994fd04 (patch) | |
tree | 58ddb29830df06a0a87524f4514c299bb22988c7 /Documentation/memory-barriers.txt | |
parent | 6ae3771850910018c89b4ce063c52008bf2c8d6a (diff) |
doc: Fix memory-barrier control-dependency example
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>
Diffstat (limited to 'Documentation/memory-barriers.txt')
-rw-r--r-- | Documentation/memory-barriers.txt | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt index fa5d8a9ae205..c8c42e64e953 100644 --- a/Documentation/memory-barriers.txt +++ b/Documentation/memory-barriers.txt | |||
@@ -531,9 +531,10 @@ dependency barrier to make it work correctly. Consider the following bit of | |||
531 | code: | 531 | code: |
532 | 532 | ||
533 | q = &a; | 533 | q = &a; |
534 | if (p) | 534 | if (p) { |
535 | <data dependency barrier> | ||
535 | q = &b; | 536 | q = &b; |
536 | <data dependency barrier> | 537 | } |
537 | x = *q; | 538 | x = *q; |
538 | 539 | ||
539 | This will not have the desired effect because there is no actual data | 540 | 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 | |||
542 | required is: | 543 | required is: |
543 | 544 | ||
544 | q = &a; | 545 | q = &a; |
545 | if (p) | 546 | if (p) { |
547 | <read barrier> | ||
546 | q = &b; | 548 | q = &b; |
547 | <read barrier> | 549 | } |
548 | x = *q; | 550 | x = *q; |
549 | 551 | ||
550 | 552 | ||