Subject: Re: auto-spl simple locks
To: Jason Thorpe <thorpej@nas.nasa.gov>
From: Chuck Silvers <chuq@chuq.com>
List: tech-kern
Date: 07/30/1999 08:15:54
On Thu, Jul 29, 1999 at 05:10:43PM -0700, Jason Thorpe wrote:
> [...]  I'll state now that auto-spl locks are the
> only sane way I can fix a locking protocol error that exists in the
> i386 pmap, even in the non-MULTIPROCESSOR case.

ok, so what's this pmap problem?


> ! static __inline void
> ! simple_lock(alp)
> ! 	__volatile struct simplelock *alp;
> ! {
> ! #if defined(MULTIPROCESSOR)
> ! 	if (alp->lock_level != LK_SPL_NONE) {
> ! 		int s = cpu_lock_spl(alp->lock_level);
> ! 		cpu_simple_lock(alp);
> ! 		alp->lock_saved_level = s;
> ! 	} else
> ! 		cpu_simple_lock(alp);
> ! #else
> ! 	if (alp->lock_level != LK_SPL_NONE)
> ! 		alp->lock_saved_level = cpu_lock_spl(alp->lock_level);
> ! #endif
> ! }


storing the old spl level in the lock like this adds the constraint that
locks must be released in the reverse order of that in which they were
acquired.  it also requires either that the spl level used for a lock be
greater than or equal to the spl level used for any locks aquired before
it, or that splraise() semantics be used for all levels in cpu_lock_spl().
if we conclude that these constraints are acceptable, they should be
enforced by LOCKDEBUG.

-Chuck