Re: why are some atomic_t's not volatile, while most are?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Chris Snook <csnook@...>
Cc: Jerry Jiang <wjiang@...>, Robert P. J. Day <rpjday@...>, Linux Kernel Mailing List <linux-kernel@...>
Date: Tuesday, August 7, 2007 - 5:38 pm

Chris Snook wrote:


Can you guarantee that the pointer dereference cannot be optimised away 
on any architecture?  Without other restrictions, a suficiently 
intelligent optimiser could notice that the address of v doesn't change 
in the loop and the destination is never written within the loop, so the 
read could be hoisted out of the loop.

Even now, powerpc (as an example) defines atomic_t as:

typedef struct { volatile int counter; } atomic_t


That volatile is there precisely to force the compiler to dereference it 
every single time.

Chris
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
why are some atomic_t's not volatile, while most are?, Robert P. J. Day, (Sun Jul 1, 8:49 am)
Re: why are some atomic_t's not volatile, while most are?, Chris Friesen, (Tue Aug 7, 11:51 am)
Re: why are some atomic_t's not volatile, while most are?, Chris Friesen, (Tue Aug 7, 5:38 pm)
Re: why are some atomic_t's not volatile, while most are?, Chris Friesen, (Wed Aug 8, 12:50 am)
Re: why are some atomic_t's not volatile, while most are?, Robert P. J. Day, (Thu Aug 9, 8:37 am)
Re: why are some atomic_t's not volatile, while most are?, Robert P. J. Day, (Thu Aug 9, 2:02 pm)
Re: why are some atomic_t's not volatile, while most are?, Robert P. J. Day, (Thu Aug 9, 2:04 pm)
Re: why are some atomic_t's not volatile, while most are?, Jan Engelhardt, (Tue Aug 7, 6:06 pm)