[PATCH] Documentation/memory-barriers: polish compiler store omit example

From: SeongJae Park
Date: Sun Feb 21 2016 - 01:18:16 EST


Comments of examples about compiler store omit in memory-barriers.txt is
about code that could be possible at that point. However, someone could
interpret the comment as an explanation about below line. This commit
exploits the intent more explicitly by adding a function call below the
comment.

Signed-off-by: SeongJae Park <sj38.park@xxxxxxxxx>
---
Documentation/memory-barriers.txt | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Documentation/memory-barriers.txt
b/Documentation/memory-barriers.txt
index 904ee42..3a17d66 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -1460,6 +1460,7 @@ of optimizations:

a = 0;
/* Code that does not store to variable a. */
+ does_not_change_a();
a = 0;

The compiler sees that the value of variable 'a' is already zero, so
@@ -1472,6 +1473,7 @@ of optimizations:

WRITE_ONCE(a, 0);
/* Code that does not store to variable a. */
+ does_not_change_a();
WRITE_ONCE(a, 0);

(*) The compiler is within its rights to reorder memory accesses unless
--
1.9.1


>
> Thanx, Paul
>
>> Thanks,
>> SeongJae Park
>>
>> >
>> > Thanx, Paul
>> >
>> >> ---
>> >> Documentation/memory-barriers.txt | 2 +-
>> >> 1 file changed, 1 insertion(+), 1 deletion(-)
>> >>
>> >> diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
>> >> index 061ff29..b4754c7 100644
>> >> --- a/Documentation/memory-barriers.txt
>> >> +++ b/Documentation/memory-barriers.txt
>> >> @@ -1471,7 +1471,7 @@ of optimizations:
>> >> wrong guess:
>> >>
>> >> WRITE_ONCE(a, 0);
>> >> - /* Code that does not store to variable a. */
>> >> + /* Code that does store to variable a. */
>> >> WRITE_ONCE(a, 0);
>> >>
>> >> (*) The compiler is within its rights to reorder memory accesses unless
>> >> --
>> >> 1.9.1
>> >>
>> >
>>
>