Messages in this thread | | | Subject | Re: memory barrier question | From | Miklos Szeredi <> | Date | Mon, 20 Sep 2010 18:01:58 +0200 |
| |
On Sun, 19 Sep 2010, Paul E. McKenney wrote: > > > Again, please put at least an ACCESS_ONCE() in. Trivial to do now, > > > possibly saving much pain and headache later on. > > > > OK, lost you here. ACCESS_ONCE() is only needed in certain situations > > (like list traversal) because some compilers can reload cached values > > across an explicit barrier (which isn't here). > > ACCESS_ONCE() also tells the compiler not to try to guess.
If the code is written like this:
if (ACCESS_ONCE(dentry->d_inode)) { blah = dentry->d_inode->i_some_field ... }
does the compiler guarantee anything or does it need a full compiler barrier to prevent reordering?
Because that pattern is, again, pretty much all over the place. Yeah it can be rewritten but that's not always feasable since it's difficult to audit, would possibly need extra function arguments, etc...
Thanks, Miklos
| |