possible deadlocks?

John Baldwin jhb at FreeBSD.org
Tue Aug 12 08:33:24 PDT 2003


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 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