Subject: Re: newlock
To: Andrew Doran <ad@NetBSD.org>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 09/02/2006 20:51:02
On Sat, Sep 02, 2006 at 04:22:15PM +0100, Andrew Doran wrote:
> 
> The *_high() variants are a special case for the guts of the kernel where
> we need to release spin locks out of order. They aren't pretty, and I'm
> not sure if they should be documented for device drivers.

I'm not sure really solve the problem either.

Since netbsd uses splraise() - so we don't have any problem about acquiring
a lock enabling some interrupts - there is no real need for the lock variants.
The unlock versions really need to transfer the original spl level to the
second lock - or swap over the saved spl levels between two locks.

Otherwise it becomes very easy to get the spl level wrong.

Releasing locks out of order is very useful, for instance:

	lock(lookup_table)
	search_for_entry();
	lock(entry);
	unlock(lookup_table);
	...
	unlock(entry);

Plausably you want to allow lock(lookup_table) to sleep, but an ISR
to be able to lock(entry);

	David

-- 
David Laight: david@l8s.co.uk