This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: spin_lock forgets to clobber memory and other smp fixes [was Re: [patch] waitqueue optimization, 2.4.0-test7]
- To: Linus Torvalds <torvalds at transmeta dot com>
- Subject: Re: spin_lock forgets to clobber memory and other smp fixes [was Re: [patch] waitqueue optimization, 2.4.0-test7]
- From: Jamie Lokier <egcs at tantalophile dot demon dot co dot uk>
- Date: Thu, 7 Sep 2000 18:55:59 +0200
- Cc: Andrea Arcangeli <andrea at suse dot de>, "David S. Miller" <davem at redhat dot com>, Ingo Molnar <mingo at elte dot hu>, linux-kernel at vger dot kernel dot org, gcc at gcc dot gnu dot org
- References: <20000907175823.B22741@pcep-jamie.cern.ch> <Pine.LNX.4.10.10009070932410.1590-100000@penguin.transmeta.com>
Linus Torvalds wrote:
> Change it to something like
>
> __asm__("":"=r" (x):"0" (x));
>
> and the "volatile" should matter.
Yes it does. Without "volatile", the asm disappears :-)
> Not for memory references, perhaps. But for the movement issues.
The compiler isn't moving memory references around "asm volatile", but
it is doing CSE around them to _eliminate_ memory references.
Thus spin_lock needs the memory clobber, to prevent CSE of non-volatile
memory references between the critical region and outside the critical
region.
Maybe spin_unlock doesn't need one because CSE doesn't work the other
way. (I'd put that clobber in anyway, to be sure).
-- Jamie