Re: [RFC] New locking primitive for 2.5

Dave Hansen
2002-02-07T19:53:14Z

Andrew Morton wrote:
> Robert Love wrote:
>>On Thu, 2002-02-07 at 10:38, Martin Wirth wrote:
>>Some of the talk I've heard has been toward an adaptive lock. These are
>>locks like Solaris's that can spin or sleep, usually depending on the
>>state of the lock's holder. Another alternative, which I prefer since
>>it is much less overhead, is a lock that spins-then-sleeps
>>unconditionally.
> I dunno. The spin-a-bit-then-sleep lock has always struck me as
> i_dont_know_what_the_fuck_im_doing_lock(). Martin's approach puts
> the decision in the hands of the programmer, rather than saying
> "Oh gee I goofed" at runtime.

The spin-then-sleep lock could be interesting as a replacement for the
BKL in places where a semaphore causes performance degredation. In
quite a few places where we replaced the BKL with a more finely grained
semapore (not a spinlock because we needed to sleep during the hold),
instead of spinning for a bit, it would schedule instead. This was bad
:). Spin-then-sleep would be great behaviour in this situation.

--
Dave Hansen
haveblue@us.ibm.com