[lkml]   [1999]   [Nov]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [patch] Re: spin_unlock optimization(i386)
Gerard wrote:
> 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.

If local speculative reads are a problem, perhaps this would be faster
than "lock; btrl $0,%0":

"movl $0,%0" then rmb().

The rmb() does a locked operation but no cross-CPU traffic on a PPro.
Thus local reads and writes are fully serialised, and bus traffic is
limited to the write which we believe is read correctly by other

The rmb() can be a separate asm so that GCC can place some register
operations in between if it's that clever (which it isn't, but it might
be one day).

OTOH, I don't see how speculative reads can be a problem. You're
speculatively reading from /outside/ a locked region so anything goes.

-- Jamie

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:55    [W:0.046 / U:3.556 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site