lkml.org 
[lkml]   [2010]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: memory barrier question
From
Date
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


\
 
 \ /
  Last update: 2010-09-20 18:05    [W:0.747 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site