From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 12 04:24:44 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9CD8C37B404; Tue, 12 Aug 2003 04:24:44 -0700 (PDT) Received: from cirb503493.alcatel.com.au (c211-28-27-130.belrs2.nsw.optusnet.com.au [211.28.27.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0408E43F75; Tue, 12 Aug 2003 04:24:43 -0700 (PDT) (envelope-from PeterJeremy@optushome.com.au) Received: from cirb503493.alcatel.com.au (localhost.alcatel.com.au [127.0.0.1])h7CBOfgh066997; Tue, 12 Aug 2003 21:24:41 +1000 (EST) (envelope-from jeremyp@cirb503493.alcatel.com.au) Received: (from jeremyp@localhost) by cirb503493.alcatel.com.au (8.12.8/8.12.8/Submit) id h7CBOemJ066996; Tue, 12 Aug 2003 21:24:40 +1000 (EST) Date: Tue, 12 Aug 2003 21:24:40 +1000 From: Peter Jeremy To: Ted Unangst Message-ID: <20030812112440.GB66788@cirb503493.alcatel.com.au> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i cc: freebsd-hackers@freebsd.org Subject: Re: possible deadlocks? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Aug 2003 11:24:45 -0000 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(). Peter