Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Aug 2003 11:33:43 -0400 (EDT)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Peter Jeremy <PeterJeremy@optushome.com.au>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: possible deadlocks?
Message-ID:  <XFMail.20030812113343.jhb@FreeBSD.org>
In-Reply-To: <20030812112440.GB66788@cirb503493.alcatel.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help

On 12-Aug-2003 Peter Jeremy wrote:
> On Mon, Aug 11, 2003 at 03:50:26PM -0700, Ted Unangst wrote:
>>On Mon, 11 Aug 2003, John Baldwin wrote:
>>> 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.
>>
>>They are the same.  SK_IF_LOCK is called on the sk_if_softc, but just
>>locks the shared sk_softc mutex.  Does that make sense?
>>
>>#define SK_LOCK(_sc)            mtx_lock(&(_sc)->sk_mtx)
>>#define SK_IF_LOCK(_sc)         mtx_lock(&(_sc)->sk_softc->sk_mtx)
> 
> This strikes me as a particularly poor selection of macros.  They
> look like they are different locks and I'm sure John won't be the
> only person who gets caught believing they really are different.
> 
> Getting locking right is difficult enough without having the same lock
> called different things in different places.  This is an area where
> C++ would be cleaner - you have two (inline) functions with the same
> name and the compiler picks the appropriate one based on the argument
> type.  Failing that, I think the code would be cleaner without the
> macros or with SK_IF_LOCK() references replaced by SK_LOCK().

Definitely agreed.  That is gross.

-- 

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



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