Re: [patch] spinlocks: remove 'volatile'

Linus Torvalds
2006-07-09T22:19:18Z

On Sun, 9 Jul 2006, Pavel Machek wrote:
>
> volatile int a; a=1; a=2;
>
> ...under old definition, there's nothing to optimize but AFAICT, your
> definition allows optimizing out a=1.

If 'a' can alias anything, then by definition the first 'a=1' could have
changed something else than the second one. Otherwise, it couldn't have
aliased "anything", it would have aliased only something _particular_.

IOW, you can think of "aliasing anything" as being equivalent to saying
"the address is indeterminate". Two writes could literally go to two
different things.

But yeah, maybe that's not really perfect either. It leaves the
read-vs-read orderign still open.

Linus