Re: [patch] spinlocks: remove 'volatile'
From: Krzysztof Halasa
Date: Sun Jul 09 2006 - 06:56:05 EST
Chase Venters <chase.venters@xxxxxxxxxxxx> writes:
>> Sure, but a barrier alone isn't enough. You have to use assembler and
>> it's beyond scope of C volatile.
>
> Right, which is why volatile is wrong.
In this case (and not only this). Of course. But not always.
> You need the barrier for both the CPU and the compiler.
For spinlocks, yes.
For other things... Sometimes you need a barrier for the compiler
only. Sometimes you don't need any general barrier, you only need
to make sure a single variable isn't being cached (by the compiler).
That's what volatile is for.
Saying that volatile is always wrong looks to me like saying that goto
is always wrong :-) And yes, there are people who say that every single
goto in the universe is wrong.
--
Krzysztof Halasa
-
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/