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: Andrea Arcangeli <andrea at suse dot de>
- Subject: Re: spin_lock forgets to clobber memory and other smp fixes [was Re: [patch] waitqueue optimization, 2.4.0-test7]
- From: Jamie Lokier <lk at tantalophile dot demon dot co dot uk>
- Date: Thu, 7 Sep 2000 17:58:23 +0200
- Cc: "David S. Miller" <davem at redhat dot com>, Ingo Molnar <mingo at elte dot hu>, Linus Torvalds <torvalds at transmeta dot com>, linux-kernel at vger dot kernel dot org, gcc at gcc dot gnu dot org
- References: <Pine.LNX.4.21.0009041922260.10246-100000@inspiron.random> <Pine.LNX.4.21.0009071653350.7236-100000@inspiron.random>
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__.
> int a = *p;
> __asm__ __volatile__("" : :);
> a = *p;
>
> (to do two explicit reads)
Sorry, that does just one read, kgcc (old stable gcc) and also with
gcc-2.96. Type aliasing on/off makes no difference to the number of reads.
Again, __volatile__ makes no difference.
I cannot tell from the GCC manual whether either of these behaviours is
correct or not.
-- Jamie