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

Gerard Roudier (groudier@club-internet.fr)
Sun, 21 Nov 1999 16:25:17 +0100 (MET)


On Sun, 21 Nov 1999, Ingo Molnar wrote:

> On Sat, 20 Nov 1999, Manfred Spraul wrote:
>
> > the current spin_unlock asm code is
> > "lock; btrl $0,%0"
> > it takes ~ 22 ticks on my PII/350.
> >
> > I think it's possible to replace that with
> > "movl $0,%0"
> > which would be a simple, pairable single-tick instruction.

[ ... ]

> (my 8-way SMP box appears to be just fine after this change, under heavy
> load. dbench numbers are visibly up, 252MB/sec instead of 242MB/sec)
>
> i'm really happy about this - there are tons of places that are using
> spin_unlock, and this effectively cuts the cost of spinlocks into half.

Hmmm... Could it be that we are just playing too much with spinlocks. ;)

Even if the simple 'mov' may ensure other processors to have a consistent
view of the spinlock, it does not prevent the CPU that unlocks from
playing with speculative execution around the 'unlock' and perform
speculative reads for example. Without a minimal serialization this stuff
does not seem safe to me, or at least not for ever.

Gérard.

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