Re: [patch] new spinlock variant, spinlock-2.3.30-A4

Manfred (manfreds@colorfullife.com)
Sat, 4 Dec 1999 09:45:10 +0100


From: Andrea Arcangeli <andrea@suse.de>
>
> The point is that a read should be considered speculative (waiting to be
> invalidated) until the write is _visible_ to all the other CPUs.
>
That's impossible. When the write from cpu2 arrives at the first cpu, then
the read instruction has retired _long_ ago.

The cpu cannot undo retired instructions. (they are retired, ie the cpu has
finished that instructions, it has already forgotten that it has executed
that instruction, side-effects of the instruction are externally observable)

read instructions are
* executed _before_ they retire.
* it seems that the cpu reevaluates read instructions if a write instruction
arrives over the memory bus (AFAICS we do not rely on this)

write instruction are
* _never_ visible before the instruction retires.
* even after they retire, they are not immediately externally visible
[obvious: the FSB runs at 100 MHz, the core at 500+Mhz: there are at least 4
cycles before the instruction could become visible. In reality, this is
_far_ longer]

> But if a read happens between XXX and YYY, then - to preserve
> processor ordering - the hardware should invalidate [...]

processor ordering is only enforced on single cpu systems.
[eg: 2 cpus execute a conflicting write operation in _exactly_ the same cpu
tick, which one should win?]

--
    Manfred

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/