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 [wasRe: [patch] waitqueue optimization, 2.4.0-test7]
- To: Jamie Lokier <lk at tantalophile dot demon dot co dot uk>
- Subject: Re: spin_lock forgets to clobber memory and other smp fixes [wasRe: [patch] waitqueue optimization, 2.4.0-test7]
- From: Linus Torvalds <torvalds at transmeta dot com>
- Date: Thu, 7 Sep 2000 09:38:28 -0700 (PDT)
- 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
On Thu, 7 Sep 2000, Jamie Lokier wrote:
> asm *__volatile__* seems to make no difference. I've tried a few things.
>
> Andrea Arcangeli wrote:
> > Maybe we can rely on the __volatile__ statement of the asm that will
> > enforce that if we write:
> >
> > *p = 0;
> > __asm__ __volatile__("" : :);
> > *p = 1;
> >
> > in the assembler we'll then find both a write of 0 and then a write of 1
> > to memory.
>
> That does 2 writes with gcc-2.96 and also egcs-2.91.66/19990314
> (Red Hat's kgcc), with or without -fstrict-aliasing.
>
> It also does 2 writes without __volatile__.
Your test is broken.
Read the gcc documentation. A inline asm with no outputs is implicitly
considered volatile. So _both_ your tests had volatile there.
Now, that may not matter that much fo ryour test-case: gcc gets careful
around inline asm anyway, even without the volatile.
Change it to something like
__asm__("":"=r" (x):"0" (x));
and the "volatile" should matter.
Not for memory references, perhaps. But for the movement issues.
Linus