Re: [patch] spinlocks: remove 'volatile'
From: Linus Torvalds
Date: Sun Jul 09 2006 - 18:17:33 EST
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/