Re: spin_lock forgets to clobber memory and other smp fixes [was Re: [patch] waitqueue optimization, 2.4.0-test7]

From: Jamie Lokier (
Date: Thu Sep 07 2000 - 10:58:23 EST

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
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

This archive was generated by hypermail 2b29 : Thu Sep 07 2000 - 21:00:30 EST