From owner-freebsd-current@FreeBSD.ORG Wed Mar 4 18:06:12 2009 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C3652106564A for ; Wed, 4 Mar 2009 18:06:12 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 94E628FC14 for ; Wed, 4 Mar 2009 18:06:12 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (pool-98-109-39-197.nwrknj.fios.verizon.net [98.109.39.197]) by cyrus.watson.org (Postfix) with ESMTPSA id 10DF246B9F; Wed, 4 Mar 2009 13:06:12 -0500 (EST) Received: from localhost (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id n24I66Ya096829; Wed, 4 Mar 2009 13:06:06 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: barney_cordoba@yahoo.com Date: Wed, 4 Mar 2009 13:05:54 -0500 User-Agent: KMail/1.9.7 References: <415008.75717.qm@web63902.mail.re1.yahoo.com> In-Reply-To: <415008.75717.qm@web63902.mail.re1.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200903041305.54726.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Wed, 04 Mar 2009 13:06:06 -0500 (EST) X-Virus-Scanned: ClamAV 0.94.2/9067/Wed Mar 4 05:06:09 2009 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: current@freebsd.org Subject: Re: MTX Lock implementation question X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Mar 2009 18:06:13 -0000 On Wednesday 04 March 2009 12:34:40 pm Barney Cordoba wrote: > > --- On Wed, 3/4/09, John Baldwin wrote: > > > From: John Baldwin > > Subject: Re: MTX Lock implementation question > > To: freebsd-current@freebsd.org, barney_cordoba@yahoo.com > > Cc: current@freebsd.org > > Date: Wednesday, March 4, 2009, 10:13 AM > > On Wednesday 04 March 2009 7:54:32 am Barney Cordoba wrote: > > > > > > Suppose the following: > > > > > > Module foo.c > > > > > > foo_getlock(sc) > > > { > > > FOO_LOCK(sc); > > > } > > > foo_unlock(sc) > > > { > > > FOO_UNLOCK(sc); > > > } > > > foo_dosomething(sc) > > > { > > > MTX_LOCK_ASSERT(sc); > > > foo_dooit(); > > > } > > > > > > Module bar.c > > > > > > bar_dofoo() > > > { > > > foo_getlock(sc); > > > foo_dosomething(sc); > > > foo_unlock(sc); > > > } > > > > This works fine. > > > > > Is this something that shouldn't work? I need to > > access functions > > > that require locks in a different module, but this > > code barfs on > > > ASSERT with witness enabled. Is this a deflugalty in > > WITNESS, or do > > > I need to create functions within foo that do the > > locking? Its been > > > working ok for awhile (its not a high volume function) > > but when I > > > fired up witness to debug something else I encountered > > witness panics. > > > > You probably have a real bug that WITNESS is warning about > > however. > > > > -- > > John Baldwin > > It seems that theres a problem when the mutex is initialized with a type > of NULL. Changing it to a non-null string eliminated the issue. I'm > running a 7.0 base system. Hmm, mutexes are required to be named. The "type" argument is optional, but the name is not. So you can't do: mtx_init(&m, NULL, NULL, MTX_DEF); You can, however do: mtx_init(&m, "foo", NULL, MTX_DEF); -- John Baldwin