On Fri, Apr 07, 2017 at 10:15:07AM +0100, Will Deacon wrote: > On Fri, Apr 07, 2017 at 02:37:36PM +0800, pierre Kuo wrote: > > for below example, if MAX is defined to be 1, then the compiler knows (Q > > % MAX) is equal to zero. > > so compiler will transform the "else" part of code. > > > > q = READ_ONCE(a); > > if (q % MAX) { > > WRITE_ONCE(b, 1); > > do_something(); > > } else { > > WRITE_ONCE(b, 2); > > do_something_else(); > > } > > > > So we modify the original document as below: > > > > q = READ_ONCE(a); > > - WRITE_ONCE(b, 1); > > + WRITE_ONCE(b, 2); > > do_something_else(); > > > > Signed-off-by: pierre Kuo <vichy.kuo@xxxxxxxxx> > > --- > > Documentation/memory-barriers.txt | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > Yup, looks like a typo since the do_something_else() part is correct. > Thanks for the fix: > > Acked-by: Will Deacon <will.deacon@xxxxxxx> > > I'm assuming somebody will pick this up. I have queued it with you ack, thank you both! Thanx, Paul > Will > > > diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt > > index d2b0a8d..08329cb 100644 > > --- a/Documentation/memory-barriers.txt > > +++ b/Documentation/memory-barriers.txt > > @@ -768,7 +768,7 @@ equal to zero, in which case the compiler is within its rights to > > transform the above code into the following: > > > > q = READ_ONCE(a); > > - WRITE_ONCE(b, 1); > > + WRITE_ONCE(b, 2); > > do_something_else(); > > > > Given this transformation, the CPU is not required to respect the ordering > > -- > > 1.9.1 > > > -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html