Re: spin_unlock optimization(i386)

Manfred Spraul (manfreds@colorfullife.com)
Fri, 26 Nov 1999 12:23:35 +0100


Erich Boleyn wrote:
>
> But, it is not needed to avoid any kind of re-ordering that IA32 will
> do. I still maintain that.
>
> IA32 just doesn't do program visible reordering. Any reordering is
> done only as a performance enhancement and with temporary results that
> are checked prior to becoming committed state.
>
It's invisible on single CPU system, but clearly visible on SMP:

* you (speculatively) execute read instructions ahead of write
instructions.
* you do not send write instructions immediately out of the CPU core,
they sit in a write buffer.
* the write buffer is private to each CPU.
* on _single_ cpu, you correct the effects of the reordering (ie if a
write sits in the write buffer, and I reread that memory address, the
the CPU notices that, and uses the new value from the write
buffer/discards the temporary result.)

BUT: since the write buffer is private to each CPU, you cannot correct
the effects of the reordering on SMP.

The program that I sent you yesterday exploits this problem, you could
run it with a suitable tracer:
* with "lock;bts", it doesn't hang.
* with "mov", it hangs.

--
	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/