Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1338643 > unrolled thread
| Started by | SeongJae Park <sj38.park@gmail.com> |
|---|---|
| First post | 2016-02-20 07:10 +0100 |
| Last post | 2016-02-22 03:40 +0100 |
| Articles | 10 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] Documentation/memory-barriers: fix wrong comment in example SeongJae Park <sj38.park@gmail.com> - 2016-02-20 07:10 +0100
Re: [PATCH] Documentation/memory-barriers: fix wrong comment in example "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-02-20 21:00 +0100
Re: [PATCH] Documentation/memory-barriers: fix wrong comment in example SeongJae Park <sj38.park@gmail.com> - 2016-02-21 00:00 +0100
Re: [PATCH] Documentation/memory-barriers: fix wrong comment in example SeongJae Park <sj38.park@gmail.com> - 2016-02-21 19:00 +0100
Re: [PATCH] Documentation/memory-barriers: fix wrong comment in example David Howells <dhowells@redhat.com> - 2016-02-22 11:10 +0100
Re: [PATCH] Documentation/memory-barriers: fix wrong comment in example SeongJae Park <sj38.park@gmail.com> - 2016-02-22 12:10 +0100
Re: [PATCH] Documentation/memory-barriers: fix wrong comment in example David Howells <dhowells@redhat.com> - 2016-02-22 12:20 +0100
Re: [PATCH] Documentation/memory-barriers: fix wrong comment in example "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-02-22 17:40 +0100
Re: [PATCH] Documentation/memory-barriers: fix wrong comment in example SeongJae Park <sj38.park@gmail.com> - 2016-02-22 22:50 +0100
Re: [PATCH] Documentation/memory-barriers: fix wrong comment in example "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-02-22 03:40 +0100
| From | SeongJae Park <sj38.park@gmail.com> |
|---|---|
| Date | 2016-02-20 07:10 +0100 |
| Subject | [PATCH] Documentation/memory-barriers: fix wrong comment in example |
| Message-ID | <r48TT-Dy-1@gated-at.bofh.it> |
There is wrong comment in example for compiler store omit behavior. It
shows example of the problem and than problem solved version code.
However, the comment in the solved version is still same with not solved
version. Fix the wrong statement with this commit.
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
---
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
[toc] | [next] | [standalone]
| From | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-02-20 21:00 +0100 |
| Subject | Re: [PATCH] Documentation/memory-barriers: fix wrong comment in example |
| Message-ID | <r4lR7-2q1-1@gated-at.bofh.it> |
| In reply to | #1338643 |
On Sat, Feb 20, 2016 at 03:01:08PM +0900, SeongJae Park wrote: > There is wrong comment in example for compiler store omit behavior. It > shows example of the problem and than problem solved version code. > However, the comment in the solved version is still same with not solved > version. Fix the wrong statement with this commit. > > Signed-off-by: SeongJae Park <sj38.park@gmail.com> Hmmm... The code between the two stores of zero to "a" is intended to remain the same in the broken and fixed versions. So the only change is from "a = 0" to "WRITE_ONCE(a, 0)". Note that it is some other CPU that did the third store to "a". Or am I missing your point here? 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 >
[toc] | [prev] | [next] | [standalone]
| From | SeongJae Park <sj38.park@gmail.com> |
|---|---|
| Date | 2016-02-21 00:00 +0100 |
| Message-ID | <r4oFk-4B6-9@gated-at.bofh.it> |
| In reply to | #1338779 |
On Sun, Feb 21, 2016 at 4:57 AM, Paul E. McKenney <paulmck@linux.vnet.ibm.com> wrote: > On Sat, Feb 20, 2016 at 03:01:08PM +0900, SeongJae Park wrote: >> There is wrong comment in example for compiler store omit behavior. It >> shows example of the problem and than problem solved version code. >> However, the comment in the solved version is still same with not solved >> version. Fix the wrong statement with this commit. >> >> Signed-off-by: SeongJae Park <sj38.park@gmail.com> > > Hmmm... The code between the two stores of zero to "a" is intended to > remain the same in the broken and fixed versions. So the only change > is from "a = 0" to "WRITE_ONCE(a, 0)". Note that it is some other > CPU that did the third store to "a". Agree, of course. > > Or am I missing your point here? My point is about the comment. I thought the comment in broken version is saying "Below line(a = 0) says it will store to variable 'a', but it will not in actual because a compiler can omit it". However, in fixed version, because the compiler cannot omit the store now, I thought the comment also should be changed to say the difference between broken and fixed version. If I am understanding anything wrong, please let me know. 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 >> >
[toc] | [prev] | [next] | [standalone]
| From | SeongJae Park <sj38.park@gmail.com> |
|---|---|
| Date | 2016-02-21 19:00 +0100 |
| Message-ID | <r4GsA-16v-41@gated-at.bofh.it> |
| In reply to | #1338813 |
On Sun, Feb 21, 2016 at 2:25 PM, Paul E. McKenney
<paulmck@linux.vnet.ibm.com> wrote:
> On Sun, Feb 21, 2016 at 07:50:19AM +0900, SeongJae Park wrote:
>> On Sun, Feb 21, 2016 at 4:57 AM, Paul E. McKenney
>> <paulmck@linux.vnet.ibm.com> wrote:
>> > On Sat, Feb 20, 2016 at 03:01:08PM +0900, SeongJae Park wrote:
>> >> There is wrong comment in example for compiler store omit behavior. It
>> >> shows example of the problem and than problem solved version code.
>> >> However, the comment in the solved version is still same with not solved
>> >> version. Fix the wrong statement with this commit.
>> >>
>> >> Signed-off-by: SeongJae Park <sj38.park@gmail.com>
>> >
>> > Hmmm... The code between the two stores of zero to "a" is intended to
>> > remain the same in the broken and fixed versions. So the only change
>> > is from "a = 0" to "WRITE_ONCE(a, 0)". Note that it is some other
>> > CPU that did the third store to "a".
>>
>> Agree, of course.
>>
>> >
>> > Or am I missing your point here?
>>
>> My point is about the comment.
>> I thought the comment in broken version is saying "Below line(a = 0) says
>> it will store to variable 'a', but it will not in actual because a compiler can
>> omit it".
>> However, in fixed version, because the compiler cannot omit the store
>> now, I thought the comment also should be changed to say the difference
>> between broken and fixed version.
>>
>> If I am understanding anything wrong, please let me know.
>
> Hmmm... The intent of the comment is to act as a placeholder for
> arbitrary code that does not affect the value of "a". The current
> comment is clearly not doing that for you. Possible changes include:
>
> o Adding test to the comment making the intent more clear.
> o Replacing the comment with a function call, perhaps to
> does_not_change_a() or some similar name.
> o Keeping the current comment, but adding a call to something
> like does_not_change_a() after it.
>
> Other thoughts?
Ah, now I understood the original intent. Thank you for the kind explanation.
I think your third option will be most helpful for me. How about the
patch below?
BTW, the problem looks trivial rather than critical.
If you think so, feel free to ignore my patch, please.
Thanks,
SeongJae Park
========================== >3 ==========================
From 77e0b1c77d64c358b329b097cffcdacd2c484867 Mon Sep 17 00:00:00 2001
From: SeongJae Park <sj38.park@gmail.com>
Date: Sun, 21 Feb 2016 15:18:16 +0900
Subject: [PATCH] Documentation/memory-barriers: polish compiler store omit
example
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@gmail.com>
---
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
>> >>
>> >
>>
>
[toc] | [prev] | [next] | [standalone]
| From | David Howells <dhowells@redhat.com> |
|---|---|
| Date | 2016-02-22 11:10 +0100 |
| Message-ID | <r4VBi-42I-29@gated-at.bofh.it> |
| In reply to | #1338904 |
SeongJae Park <sj38.park@gmail.com> wrote: > a = 0; > /* Code that does not store to variable a. */ > + does_not_change_a(); > a = 0; Since it's not actually code that's meant to be executed, you could make it: a = 0; ... code that does not store to variable a ... a = 0; David
[toc] | [prev] | [next] | [standalone]
| From | SeongJae Park <sj38.park@gmail.com> |
|---|---|
| Date | 2016-02-22 12:10 +0100 |
| Subject | Re: [PATCH] Documentation/memory-barriers: fix wrong comment in example |
| Message-ID | <r4Wxk-4RK-37@gated-at.bofh.it> |
| In reply to | #1339310 |
On Mon, 22 Feb 2016, David Howells wrote:
> SeongJae Park <sj38.park@gmail.com> wrote:
>
>> a = 0;
>> /* Code that does not store to variable a. */
>> + does_not_change_a();
>> a = 0;
>
> Since it's not actually code that's meant to be executed, you could make it:
>
> a = 0;
> ... code that does not store to variable a ...
> a = 0;
I selected Paul's third option because the function could be noop (In this
case, it doesn't break the original meaning) and it makes the code looks
complete.
However, your suggestion looks much better than the comment, too.
So, I am attaching a patch that applying your suggestion below.
=============================== >3 ====================================
From f7b5677790771599f418f1d95536935be971ae86 Mon Sep 17 00:00:00 2001
From: SeongJae Park <sj38.park@gmail.com>
Date: Mon, 22 Feb 2016 19:26:18 +0900
Subject: [PATCH] Documentation/memory-barriers: polish compiler store omit
example
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 changing the comment to be seems
like a possible code rather than explanation about below line.
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
---
Documentation/memory-barriers.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/memory-barriers.txt
b/Documentation/memory-barriers.txt
index 904ee42..dc66351 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -1459,7 +1459,7 @@ of optimizations:
the following:
a = 0;
- /* Code that does not store to variable a. */
+ ... Code that does not store to variable a ...
a = 0;
The compiler sees that the value of variable 'a' is already zero, so
@@ -1471,7 +1471,7 @@ of optimizations:
wrong guess:
WRITE_ONCE(a, 0);
- /* Code that does not store to variable a. */
+ ... Code that does not store to variable a ...
WRITE_ONCE(a, 0);
(*) The compiler is within its rights to reorder memory accesses unless
--
1.9.1
>
> David
>
[toc] | [prev] | [next] | [standalone]
| From | David Howells <dhowells@redhat.com> |
|---|---|
| Date | 2016-02-22 12:20 +0100 |
| Message-ID | <r4WH1-4WG-49@gated-at.bofh.it> |
| In reply to | #1339352 |
SeongJae Park <sj38.park@gmail.com> wrote: > From f7b5677790771599f418f1d95536935be971ae86 Mon Sep 17 00:00:00 2001 > From: SeongJae Park <sj38.park@gmail.com> > Date: Mon, 22 Feb 2016 19:26:18 +0900 > Subject: [PATCH] Documentation/memory-barriers: polish compiler store omit > example > > 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 changing the comment to be seems > like a possible code rather than explanation about below line. > > Signed-off-by: SeongJae Park <sj38.park@gmail.com> > --- > Documentation/memory-barriers.txt | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/Documentation/memory-barriers.txt > b/Documentation/memory-barriers.txt > index 904ee42..dc66351 100644 > --- a/Documentation/memory-barriers.txt > +++ b/Documentation/memory-barriers.txt > @@ -1459,7 +1459,7 @@ of optimizations: > the following: > > a = 0; > - /* Code that does not store to variable a. */ > + ... Code that does not store to variable a ... > a = 0; > > The compiler sees that the value of variable 'a' is already zero, so > @@ -1471,7 +1471,7 @@ of optimizations: > wrong guess: > > WRITE_ONCE(a, 0); > - /* Code that does not store to variable a. */ > + ... Code that does not store to variable a ... > WRITE_ONCE(a, 0); > > (*) The compiler is within its rights to reorder memory accesses unless Acked-by: David Howells <dhowells@redhat.com>
[toc] | [prev] | [next] | [standalone]
| From | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-02-22 17:40 +0100 |
| Subject | Re: [PATCH] Documentation/memory-barriers: fix wrong comment in example |
| Message-ID | <r51GG-8uQ-1@gated-at.bofh.it> |
| In reply to | #1339380 |
On Mon, Feb 22, 2016 at 11:16:39AM +0000, David Howells wrote:
> SeongJae Park <sj38.park@gmail.com> wrote:
>
> > From f7b5677790771599f418f1d95536935be971ae86 Mon Sep 17 00:00:00 2001
> > From: SeongJae Park <sj38.park@gmail.com>
> > Date: Mon, 22 Feb 2016 19:26:18 +0900
> > Subject: [PATCH] Documentation/memory-barriers: polish compiler store omit
> > example
> >
> > 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 changing the comment to be seems
> > like a possible code rather than explanation about below line.
> >
> > Signed-off-by: SeongJae Park <sj38.park@gmail.com>
> > ---
> > Documentation/memory-barriers.txt | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/Documentation/memory-barriers.txt
> > b/Documentation/memory-barriers.txt
> > index 904ee42..dc66351 100644
> > --- a/Documentation/memory-barriers.txt
> > +++ b/Documentation/memory-barriers.txt
> > @@ -1459,7 +1459,7 @@ of optimizations:
> > the following:
> >
> > a = 0;
> > - /* Code that does not store to variable a. */
> > + ... Code that does not store to variable a ...
> > a = 0;
> >
> > The compiler sees that the value of variable 'a' is already zero, so
> > @@ -1471,7 +1471,7 @@ of optimizations:
> > wrong guess:
> >
> > WRITE_ONCE(a, 0);
> > - /* Code that does not store to variable a. */
> > + ... Code that does not store to variable a ...
> > WRITE_ONCE(a, 0);
> >
> > (*) The compiler is within its rights to reorder memory accesses unless
>
> Acked-by: David Howells <dhowells@redhat.com>
Thank you both! Patch with updated commit log below, please let me know
if you have any objections to the changes.
Thanx, Paul
------------------------------------------------------------------------
commit 0a41feb6ab4da3218192e2cde1a54fcc5d8f5658
Author: SeongJae Park <sj38.park@gmail.com>
Date: Mon Feb 22 08:28:29 2016 -0800
documentation: Clarify compiler store-fusion example
The compiler store-fusion example in memory-barriers.txt uses a C
comment to represent arbitrary code that does not update a given
variable. Unfortunately, someone could reasonably interpret the
comment as instead referring to the following line of code. This
commit therefore replaces the comment with a string that more
clearly represents the arbitrary code.
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
index 8367d393cba2..3729cbe60e41 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -1550,7 +1550,7 @@ of optimizations:
the following:
a = 0;
- /* Code that does not store to variable a. */
+ ... Code that does not store to variable a ...
a = 0;
The compiler sees that the value of variable 'a' is already zero, so
@@ -1562,7 +1562,7 @@ of optimizations:
wrong guess:
WRITE_ONCE(a, 0);
- /* Code that does not store to variable a. */
+ ... Code that does not store to variable a ...
WRITE_ONCE(a, 0);
(*) The compiler is within its rights to reorder memory accesses unless
[toc] | [prev] | [next] | [standalone]
| From | SeongJae Park <sj38.park@gmail.com> |
|---|---|
| Date | 2016-02-22 22:50 +0100 |
| Message-ID | <r56wG-3xl-3@gated-at.bofh.it> |
| In reply to | #1339705 |
On Tue, Feb 23, 2016 at 1:33 AM, Paul E. McKenney <paulmck@linux.vnet.ibm.com> wrote: > On Mon, Feb 22, 2016 at 11:16:39AM +0000, David Howells wrote: >> SeongJae Park <sj38.park@gmail.com> wrote: >> >> > From f7b5677790771599f418f1d95536935be971ae86 Mon Sep 17 00:00:00 2001 >> > From: SeongJae Park <sj38.park@gmail.com> >> > Date: Mon, 22 Feb 2016 19:26:18 +0900 >> > Subject: [PATCH] Documentation/memory-barriers: polish compiler store omit >> > example >> > >> > 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 changing the comment to be seems >> > like a possible code rather than explanation about below line. >> > >> > Signed-off-by: SeongJae Park <sj38.park@gmail.com> >> > --- >> > Documentation/memory-barriers.txt | 4 ++-- >> > 1 file changed, 2 insertions(+), 2 deletions(-) >> > >> > diff --git a/Documentation/memory-barriers.txt >> > b/Documentation/memory-barriers.txt >> > index 904ee42..dc66351 100644 >> > --- a/Documentation/memory-barriers.txt >> > +++ b/Documentation/memory-barriers.txt >> > @@ -1459,7 +1459,7 @@ of optimizations: >> > the following: >> > >> > a = 0; >> > - /* Code that does not store to variable a. */ >> > + ... Code that does not store to variable a ... >> > a = 0; >> > >> > The compiler sees that the value of variable 'a' is already zero, so >> > @@ -1471,7 +1471,7 @@ of optimizations: >> > wrong guess: >> > >> > WRITE_ONCE(a, 0); >> > - /* Code that does not store to variable a. */ >> > + ... Code that does not store to variable a ... >> > WRITE_ONCE(a, 0); >> > >> > (*) The compiler is within its rights to reorder memory accesses unless >> >> Acked-by: David Howells <dhowells@redhat.com> > > Thank you both! Patch with updated commit log below, please let me know > if you have any objections to the changes. Looks good to me :) Thanks, SeongJae Park > > Thanx, Paul > > ------------------------------------------------------------------------ > > commit 0a41feb6ab4da3218192e2cde1a54fcc5d8f5658 > Author: SeongJae Park <sj38.park@gmail.com> > Date: Mon Feb 22 08:28:29 2016 -0800 > > documentation: Clarify compiler store-fusion example > > The compiler store-fusion example in memory-barriers.txt uses a C > comment to represent arbitrary code that does not update a given > variable. Unfortunately, someone could reasonably interpret the > comment as instead referring to the following line of code. This > commit therefore replaces the comment with a string that more > clearly represents the arbitrary code. > > Signed-off-by: SeongJae Park <sj38.park@gmail.com> > Acked-by: David Howells <dhowells@redhat.com> > Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> > > diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt > index 8367d393cba2..3729cbe60e41 100644 > --- a/Documentation/memory-barriers.txt > +++ b/Documentation/memory-barriers.txt > @@ -1550,7 +1550,7 @@ of optimizations: > the following: > > a = 0; > - /* Code that does not store to variable a. */ > + ... Code that does not store to variable a ... > a = 0; > > The compiler sees that the value of variable 'a' is already zero, so > @@ -1562,7 +1562,7 @@ of optimizations: > wrong guess: > > WRITE_ONCE(a, 0); > - /* Code that does not store to variable a. */ > + ... Code that does not store to variable a ... > WRITE_ONCE(a, 0); > > (*) The compiler is within its rights to reorder memory accesses unless >
[toc] | [prev] | [next] | [standalone]
| From | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-02-22 03:40 +0100 |
| Subject | Re: [PATCH] Documentation/memory-barriers: fix wrong comment in example |
| Message-ID | <r4GsA-16v-43@gated-at.bofh.it> |
| In reply to | #1338813 |
On Sun, Feb 21, 2016 at 07:50:19AM +0900, SeongJae Park wrote: > On Sun, Feb 21, 2016 at 4:57 AM, Paul E. McKenney > <paulmck@linux.vnet.ibm.com> wrote: > > On Sat, Feb 20, 2016 at 03:01:08PM +0900, SeongJae Park wrote: > >> There is wrong comment in example for compiler store omit behavior. It > >> shows example of the problem and than problem solved version code. > >> However, the comment in the solved version is still same with not solved > >> version. Fix the wrong statement with this commit. > >> > >> Signed-off-by: SeongJae Park <sj38.park@gmail.com> > > > > Hmmm... The code between the two stores of zero to "a" is intended to > > remain the same in the broken and fixed versions. So the only change > > is from "a = 0" to "WRITE_ONCE(a, 0)". Note that it is some other > > CPU that did the third store to "a". > > Agree, of course. > > > > > Or am I missing your point here? > > My point is about the comment. > I thought the comment in broken version is saying "Below line(a = 0) says > it will store to variable 'a', but it will not in actual because a compiler can > omit it". > However, in fixed version, because the compiler cannot omit the store > now, I thought the comment also should be changed to say the difference > between broken and fixed version. > > If I am understanding anything wrong, please let me know. Hmmm... The intent of the comment is to act as a placeholder for arbitrary code that does not affect the value of "a". The current comment is clearly not doing that for you. Possible changes include: o Adding test to the comment making the intent more clear. o Replacing the comment with a function call, perhaps to does_not_change_a() or some similar name. o Keeping the current comment, but adding a call to something like does_not_change_a() after it. Other thoughts? 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 > >> > > >
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web