Re: [patch] spinlocks: remove 'volatile'

From: Avi Kivity
Date: Sat Jul 08 2006 - 04:40:39 EST


linux-os (Dick Johnson) wrote:

>> The 'C' compiler has no choice but to actually make that memory access
>> and read the variable because the variable is in another module (a.k.a.
>> file).


[code showing the compiler may cache the access]

So read the code; you have "10: jne 10", jumping to itself
forever, without even doing anything else to set the flags, much
less reading a variable.


Short attention span, eh? He's proven you wrong and you go on and talk about something else.

>
>> However, if I have the same code, but the variable is visible during
>> compile time, i.e.,
>>
>> int spinner=0;
>>
>> funct(){
>> while(spinner)
>> ;
>>
>> ... the compiler may eliminate that code altogether because it
>> 'knows' that spinner is FALSE, having initialized it to zero
>> itself.
>


[code showing that defining the variable in the same translation unit makes no difference]

Then, you have exactly the same thing here:
10: 75 fe jne 10 <funct+0x10>

Same bad code.


You seem to have forgotten that you claimed different code would be generated.

--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.

-
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/