Re: [PATCH 6/8] i386: bitops: Don't mark memory as clobbered unnecessarily

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Tuesday, July 24, 2007 - 1:08 pm

On Tue, 24 Jul 2007, Andi Kleen wrote:

Sure, that's *one* thing that "volatile" guarantees (it guarantees that 
gcc won't optimize away things where the end result isn't actually visibly 
used).

But gcc docs also talk about the other things volatile means, including 
"not significantly moved".

Is that "not significantly moved" already equivalent to "not moved past 
something that can change memory"? Probably not. Which is why it's a good 
idea to have the "memory" clobber there too, because the semantics of the 
"volatile" just aren't very well defined from a code movement standpoint 
(while a general memory clobber is *very* clear: if gcc moves the inline 
asm across another thing that uses/changes memory, that's a gcc bug, plain 
and simple (*)).

		Linus

(*) Other than pure internal gcc spills/reloads. Spilling/reloading local 
registers that haven't had their address taken obviously cannot be seen as 
memory accesses.
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/8] i386: bitops: Cleanup, sanitize, optimize, Satyam Sharma, (Mon Jul 23, 9:05 am)
[PATCH 1/8] i386: bitops: Update/correct comments, Satyam Sharma, (Mon Jul 23, 9:05 am)
Re: [PATCH 7/8] i386: bitops: Kill needless usage of __asm ..., Jeremy Fitzhardinge, (Mon Jul 23, 9:23 am)
Re: [PATCH 7/8] i386: bitops: Kill needless usage of __asm ..., Jeremy Fitzhardinge, (Mon Jul 23, 10:39 am)
Re: [PATCH 6/8] i386: bitops: Don't mark memory as clobber ..., Jeremy Fitzhardinge, (Mon Jul 23, 10:49 am)
Re: [PATCH 7/8] i386: bitops: Kill needless usage of __asm ..., Jeremy Fitzhardinge, (Mon Jul 23, 11:28 am)
Re: [PATCH 7/8] i386: bitops: Kill needless usage of __asm ..., Jeremy Fitzhardinge, (Mon Jul 23, 1:40 pm)
Re: [PATCH 8/8] i386: bitops: smp_mb__{before, after}_clea ..., Jeremy Fitzhardinge, (Tue Jul 24, 12:48 am)
Re: [PATCH 4/8] i386: bitops: Kill volatile-casting of mem ..., Benjamin Herrenschmidt, (Tue Jul 24, 2:49 am)
Re: [PATCH 6/8] i386: bitops: Don't mark memory as clobber ..., Benjamin Herrenschmidt, (Tue Jul 24, 2:52 am)
Re: [PATCH 6/8] i386: bitops: Don't mark memory as clobber ..., Linus Torvalds, (Tue Jul 24, 1:08 pm)
Re: [PATCH 6/8] i386: bitops: Don't mark memory as clobber ..., Jeremy Fitzhardinge, (Tue Jul 24, 2:31 pm)
Re: [PATCH 6/8] i386: bitops: Don't mark memory as clobber ..., Benjamin Herrenschmidt, (Tue Jul 24, 2:36 pm)
Re: [PATCH 6/8] i386: bitops: Don't mark memory as clobber ..., Benjamin Herrenschmidt, (Tue Jul 24, 2:37 pm)
Re: [PATCH 6/8] i386: bitops: Don't mark memory as clobber ..., Benjamin Herrenschmidt, (Tue Jul 24, 3:32 pm)
Re: [PATCH 0/8] i386: bitops: Cleanup, sanitize, optimize, Denis Vlasenko, (Mon Jul 30, 10:57 am)
Re: [PATCH 0/8] i386: bitops: Cleanup, sanitize, optimize, Satyam Sharma, (Mon Jul 30, 6:07 pm)