Re: [PATCH] mm: prevent mmap_cache race in find_vma()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 3 Apr 2013, Johannes Weiner wrote:

> > As stated, it doesn't.  I made the comment "for what it's worth" that 
> > ACCESS_ONCE() doesn't do anything to "prevent the compiler from 
> > re-fetching" as the changelog insists it does.
> 
> That's exactly what it does:
> 
> /*
>  * Prevent the compiler from merging or refetching accesses.
> 
> This is the guarantee ACCESS_ONCE() gives, users should absolutely be
> allowed to rely on this literal definition.  The underlying gcc
> implementation does not matter one bit.  That's the whole point of
> abstraction!
> 

The C99 and earlier C standards do not provide any way of "preventing the 
compiler from refetching accesses," and in fact C99 leaves an access to a 
volatile qualified object as implementation defined.  (If you disagree, 
then specify what exactly about ACCESS_ONCE() prevents the compiler from 
doing so.)

I agree that comment is confusing unless you specify that gcc's 
implementation provides that guarantee and I would tend to agree with 
Paul's assessment that the wide majority (all?) of compilers do the same.  
I would hesitate to say positively that gcc will continue to implement 
anything in the future other than what the standard specifies, though.  
But I do agree that the comment is confusing.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]