lkml.org 
[lkml]   [1996]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Is clobber "memory" in include/asm-i386/system.h necessary?


On Sat, 4 May 1996, Warner Losh wrote:
>
> : "volatile" itself causes suboptimal code to be generated
> : even in places where it's unnecessary, such as between cli() and sti().
>
> What about MP machines? Wouldn't volatile still be needed between a
> cli() and sti() because other processors might change the value out
> from under you? Granted, a higher level of locking would prevent
> that, but there are cases where you might want that to happen (like in
> the lock manager code, assuming it uses atomic memory access
> instructions).

"volatile" is _never_ a good idea, even in SMP. You already touched on
why it's not a good idea: it's unnecessary if we have some locking to
prevent concurrent accesses.

Now, if we DON'T have locking that prevents concurrent accesses, then we
have a major bug in the system.

Ergo, using "volatile" means that we have a major bug in the system.

QED.

Linus


\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.038 / U:0.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site