On Wed, 2016-11-30 at 15:28 +0000, David Laight wrote: > Are you sure??
Yes I am > Last I looked gcc seemed to convert 'foo++' to 'foo = foo + 1' before > generating any code. Your gcc might need a refresh then. > It might then optimise that back to a memory increment, but that would > also happen if you'd coded the latter form. > > > Which is kind of unfortunate, given it is the fast path. > > > > Better add a comment, like : > > > > /* We should use WRITE_ONCE() to pair with the READ_ONCE() found in xxxx() > > * But gcc would generate non optimal code. > > */ > > Actually while READ_ONCE() is generally useful - to get a snapshot of a > changing value. > > WRITE_ONCE() isn't a pairing - the compiler is highly unlikely to write a > location twice. WOW. I can not believe what you just said. We had numerous bugs because compiler was writing on the location temporary computations. Just take a look at git history to find some gems. > You might want an annotation to ensure is doesn't assume it can read the value > back (write through volatile pointer). But that has nothing to do with how > readers behave. Completely wrong.