possible deadlocks?

John Baldwin jhb at FreeBSD.org
Mon Aug 11 15:02:56 PDT 2003


On 11-Aug-2003 Ted Unangst wrote:
> one more.  This falls into the very improbable category.  Ordinarily, I
> don't think this is possible because FreeBSD doesn't support hotplug PCI,
> so sk attachment can't be raced.
> 
> However, assuming I had some hot plug sk card, it seems like running
> ifconfig sk0 at just the wrong point during sk1 attach will deadlock.  If
> it absolutely can not happen (for a reason other than sk is attached
> before init runs) please explain.
> 
> sk.c:
>   sk_attach_xmac()
>     SK_LOCK(sc); /* grabs */
>     ether_ifattach()
>       ifattach()
>         IFNET_WLOCK() /* waits for 2 */
> 
> in6_ifattach.c:
>   in6_nigroup_attach()
>     IFNET_RLOCK() /* grabs */
>     in6_addmulti()
>       if_addmulti()
>         sk_ioctl()
>         SK_IF_LOCK();  /* waits for 1 */

You can't ifconfig sk0 until after it attaches.  sk0 and sk1 don't
share locks, so you don't have to worry about the interaction there.
Also, SK_LOCK != SK_IF_LOCK, or is that a typo?  If it is a typo,
then the lock order should still be fixed in some fashion.

-- 

John Baldwin <jhb at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/


More information about the freebsd-hackers mailing list