From owner-p4-projects@FreeBSD.ORG Thu Jan 31 12:16:29 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 836B716A52C; Thu, 31 Jan 2008 12:16:29 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 302B916A502 for ; Thu, 31 Jan 2008 12:16:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail.speedfactory.net [66.23.216.219]) by mx1.freebsd.org (Postfix) with ESMTP id 9E57913C43E for ; Thu, 31 Jan 2008 12:16:28 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.8s) with ESMTP id 230312693-1834499 for multiple; Thu, 31 Jan 2008 07:15:06 -0500 Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.2/8.14.2) with ESMTP id m0VCFpqd018988; Thu, 31 Jan 2008 07:16:20 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: John Birrell Date: Thu, 31 Jan 2008 06:31:54 -0500 User-Agent: KMail/1.9.7 References: <200801272148.m0RLmWdF053919@repoman.freebsd.org> <200801300913.03782.jhb@freebsd.org> <20080130205204.GA68541@what-creek.com> In-Reply-To: <20080130205204.GA68541@what-creek.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200801310631.54935.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]); Thu, 31 Jan 2008 07:16:20 -0500 (EST) X-Virus-Scanned: ClamAV 0.91.2/5622/Thu Jan 31 06:00:29 2008 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: Perforce Change Reviews Subject: Re: PERFORCE change 134245 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jan 2008 12:16:29 -0000 On Wednesday 30 January 2008 03:52:04 pm John Birrell wrote: > On Wed, Jan 30, 2008 at 09:13:03AM -0500, John Baldwin wrote: > > On Sunday 27 January 2008 04:48:32 pm John Birrell wrote: > > > http://perforce.freebsd.org/chv.cgi?CH=134245 > > > > > > Change 134245 by jb@jb_freebsd1 on 2008/01/27 21:47:41 > > > > > > The linker lock here is private to code in this file. It is > > > never a problem with it being locked when any other combination > > > of locks are already obtained or even if *no* other locks are > > > obtained. Use SX_NOWITNESS to avoid bogus LOR reports. > > > > If witness reports a LOR it is real, it may just not be obvious. > > Here is some code that demonstrates the problem: > > > static struct mtx test_mtx; > MTX_SYSINIT(test, &test_mtx, "Test", MTX_DEF); > > static int > test_list(linker_file_t lf, void *arg) > { > printf("Linker file name: '%s'\n", lf->filename); > return (0); > } > > static void > test_thread_func(void *arg) > { > printf("\n\nI'm a big bad thread, but I'm going to wait a bit... stay tuned...\n"); > > pause("Waiting a bit...", 5000); > > printf("The big bad thread is awake and he wants to list the linker files...\n"); > > linker_file_foreach(test_list, NULL); > > printf("Lock my wide scope mutex because I have stuff to protect...\n"); > > mtx_lock(&test_mtx); > > printf("I've done some stuff that my wide scope lock protected, but now I need to list some linker files...\n"); > > linker_file_foreach(test_list, NULL); This acquires an sx lock (KLD_LOCK) while holding a mutex which isn't permitted as kris@ mentioned in his previous e-mail. Just make test_mtx an sx lock and witness should be fine. Either that or acquire your mutex in the function that linker_file_foreach() invokes rather than holding it while calling into the linker. -- John Baldwin