I wrote: > Herbert Xu wrote: >> On Thu, Aug 16, 2007 at 10:06:31AM +0200, Stefan Richter wrote: [...] >>> expectation that each >>> occurrence of atomic_read actually results in a load operation, i.e. is >>> not optimized away. [...] >> Can you find an actual atomic_read code snippet there that is >> broken without the volatile modifier?
PS: Just to clarify, I'm not speaking for the volatile modifier. I'm not speaking for any particular implementation of atomic_t and its accessors at all. All I am saying is that - we use atomically accessed data types because we concurrently but locklessly access this data, - hence a read access to this data that could be optimized away makes *no sense at all*. The only sensible read accessor to an atomic datatype is a read accessor that will not be optimized away. So, the architecture guys can implement atomic_read however they want --- as long as it cannot be optimized away.* PPS: If somebody has code where he can afford to let the compiler coalesce atomic_read with a previous access to the same data, i.e. doesn't need and doesn't want all guarantees that the atomic_read API makes (or IMO should make), then he can replace the atomic_read by a local temporary variable. *) Exceptions: if (known_to_be_false) read_access(a); and the like. -- Stefan Richter -=====-=-=== =--- =---- http://arcgraph.de/sr/ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/