Re: [patch] Re: spin_unlock optimization(i386)

Jeff V. Merkey (jmerkey@timpanogas.com)
Sun, 21 Nov 1999 17:37:16 -0700


What Linus says here is correct for PPro and above. Using a mov
instruction to unlock does work fine on a 486 or Pentium SMP system, but
as of the PPro, this was no longer the case, though the window is so
infintesimally small, most kernels don't hit it (Netware 4/5 uses this
method but it's spinlocks understand this and the code is writtne to
handle it. The most obvious aberrant behavior was that cache
inconsistencies would occur randomly. PPro uses lock to signal that the
piplines are no longer invalid and the buffers should be blown out.

I have seen the behavior Linus describes on a hardware analyzer, BUT
ONLY ON SYSTEMS THAT WERE PPRO AND ABOVE. I guess the BSD people must
still be on older Pentium hardware and that's why they don't know this
can bite in some cases.

Jeff

Linus Torvalds wrote:
>
> On Sun, 21 Nov 1999, Manfred Spraul wrote:
> >
> > You have reordered write _ahead_ of read, and the effects were
> > externally visible.
> > This cannot happen:
>
> Not on a Pentium.
>
> But I quote (from the PPro manual):
>
> "The only enhancement in the PentiumPro processor is the added support
> for speculative reads and store-buffer forwarding, .."
>
> A Pentium is a in-order machine, without any of the interesting
> speculation wrt reads etc. So on a Pentium you'll never see the problem.
>
> But a Pentium is also very uninteresting from a SMP standpoint these days.
> It's just too weak with too little per-CPU cache etc..
>
> This is why the PPro has the MTRR's - exactly to let the core do
> speculation (a Pentium doesn't need MTRR's, as it won't re-order anything
> external to the CPU anyway, and in fact won't even re-order things
> internally).
>
> Linus
>
> -
> 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/

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