Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Feb 2009 08:36:28 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        "M. Warner Losh" <imp@bsdimp.com>
Cc:        src-committers@freebsd.org, thompsa@freebsd.org, svn-src-user@freebsd.org
Subject:   Re: svn commit: r187978 - user/thompsa/usb/sys/dev/usb2/ethernet
Message-ID:  <200902020836.28882.jhb@freebsd.org>
In-Reply-To: <20090201.203618.1640016624.imp@bsdimp.com>
References:  <200902010650.n116obU1045871@svn.freebsd.org> <20090201213749.GJ32503@citylink.fud.org.nz> <20090201.203618.1640016624.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sunday 01 February 2009 10:36:18 pm M. Warner Losh wrote:
> In message: <20090201213749.GJ32503@citylink.fud.org.nz>
>             Andrew Thompson <thompsa@FreeBSD.org> writes:
> : On Sun, Feb 01, 2009 at 02:28:08PM -0700, M. Warner Losh wrote:
> : > In message: <200902010650.n116obU1045871@svn.freebsd.org>
> : >             Andrew Thompson <thompsa@FreeBSD.org> writes:
> : > : +	locked = mtx_owned(&sc->sc_mtx);
> : > : +	if (!locked)
> : > : +		AUE_LOCK(sc);
> : > 
> : > You do know this is racy, right?

Err, no it's not.  Individual threads are always "single-threaded", so whether 
or not a given thread holds a lock is actually deterministic.  This is 
perfectly fine, and is actually how recursive locks work.

> : Yea... It only get called unlocked during mii probe+attach so its fine.
> : I havnt actaully checked if its ok to hold a mutex during
> : mii_phy_probe() which would make this go away.
> 
> You hold GIANT when probe+attach, which means I think you can't
> acquire any other locks...

That's completely backwards.  :)  You can definitely acquire other locks while 
holding Giant.  What you can't do is acquire Giant while holding another 
mutex.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902020836.28882.jhb>