Subject: Re: newlock
To: Andrew Doran <ad@netbsd.org>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 09/11/2006 11:07:36
--+QahgC5+KEYLbs62
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Sep 08, 2006 at 06:46:17PM +0100, Andrew Doran wrote:
> On Fri, Sep 08, 2006 at 09:49:34AM -0700, Jason Thorpe wrote:
>=20
> > Can you explain to me again how the link/exit_linked stuff will work?  =
=20
> > I want to make sure I have my head wrapped around it properly. :-)
>=20
> It would look something like this:
>=20
> 	mutex_enter(a);
> 	mutex_enter(b);

Note, we have a potential issue here as well. In addition to the necessity
of a locking order, if both locks are driver locks (have IPL cookies),=20
then we have to make sure we grab them in the right order.

Since IPLs change from arch to arch, I think it's best to establish one=20
locking hierarchy, then have a routine that can cope with needing to=20
release a to get b. And code will have to cope with the lock potentially=20
being dropped while getting b.

> 	mutex_exit_linked(a, b);
> 	mutex_exit(b);
>=20
> 	void
> 	mutex_exit_linked(kmutex_t from, kmutex_t to)
> 	{
> 		to->mtx_oldspl =3D from->mtx_oldspl;
> 		MUTEX_SPIN_RELEASE(from);
> 	}

That's probably fine.

Take care,

Bill

--+QahgC5+KEYLbs62
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (NetBSD)

iD8DBQFFBaXoWz+3JHUci9cRAuvbAKCTREM/QDiIasWgx2Oov5EqpXq1UQCdFjQf
UfTIgkzuJIMAlyGnxtFrcGA=
=dQgS
-----END PGP SIGNATURE-----

--+QahgC5+KEYLbs62--