From owner-freebsd-current@FreeBSD.ORG Wed Feb 11 14:50:39 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 521E610656CC for ; Wed, 11 Feb 2009 14:50:39 +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 227A08FC23 for ; Wed, 11 Feb 2009 14:50:39 +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 A872A46B3C; Wed, 11 Feb 2009 09:50:38 -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 n1BEo9FD025248; Wed, 11 Feb 2009 09:50:32 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: Sean Bruno Date: Wed, 11 Feb 2009 09:46:45 -0500 User-Agent: KMail/1.9.7 References: <1234315393.14556.6.camel@localhost.localdomain> <1234332568.14556.11.camel@localhost.localdomain> In-Reply-To: <1234332568.14556.11.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200902110946.46153.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, 11 Feb 2009 09:50:32 -0500 (EST) X-Virus-Scanned: ClamAV 0.94.2/8979/Wed Feb 11 07:23:15 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: freebsd-current@freebsd.org Subject: Re: [sysctl] New sysctl LoR today 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, 11 Feb 2009 14:50:39 -0000 On Wednesday 11 February 2009 1:09:28 am Sean Bruno wrote: > On Tue, 2009-02-10 at 17:23 -0800, Sean Bruno wrote: > > I'm working on some items in the firewire stack and after a update, I > > was greeted with a new LoR against the SYSCTL lock. I noted that some > > things were changing in that space. > > > > Did I miss an interface change that I need to pickup in the firewire > > stack? > > > > Sean > > > > lock order reversal: (sleepable after non-sleepable) > > 1st 0xc471bbec sbp (sbp) @ dev/firewire/sbp.c:2253 > > 2nd 0xc0d3aea4 sysctl lock (sysctl lock) @ kern/kern_sysctl.c:250 > > KDB: stack backtrace: > > _sx_xlock(c0d3aea4,0,c0be5d46,fa,c471a000,...) at _sx_xlock+0x85 > > sysctl_ctx_free(c471a2c0,c0b8f786,c0d0696c,0,c469fa0c,...) at > > sysctl_ctx_free+0x30 > > dacleanup(c4c54700,c0b900bb,c480e000,c42aa410,246,...) at dacleanup+0x35 > > camperiphfree(c4c54700,c4c54700,c42aa694,c047763d,c4c54700,...) at No, this is due to CAM calling sysctl_ctx_free() with a lock held. You can try this change: --- //depot/user/jhb/lock/cam/scsi/scsi_cd.c +++ /home/jhb/work/p4/lock/cam/scsi/scsi_cd.c @@ -401,11 +401,6 @@ xpt_print(periph->path, "removing device entry\n"); - if ((softc->flags & CD_FLAG_SCTX_INIT) != 0 - && sysctl_ctx_free(&softc->sysctl_ctx) != 0) { - xpt_print(periph->path, "can't remove sysctl context\n"); - } - /* * In the queued, non-active case, the device in question * has already been removed from the changer run queue. Since this @@ -474,9 +469,14 @@ free(softc->changer, M_DEVBUF); } cam_periph_unlock(periph); + if ((softc->flags & CD_FLAG_SCTX_INIT) != 0 + && sysctl_ctx_free(&softc->sysctl_ctx) != 0) { + xpt_print(periph->path, "can't remove sysctl context\n"); + } + disk_destroy(softc->disk); + free(softc, M_DEVBUF); cam_periph_lock(periph); - free(softc, M_DEVBUF); } static void --- //depot/user/jhb/lock/cam/scsi/scsi_da.c +++ /home/jhb/work/p4/lock/cam/scsi/scsi_da.c @@ -995,6 +995,8 @@ softc = (struct da_softc *)periph->softc; xpt_print(periph->path, "removing device entry\n"); + cam_periph_unlock(periph); + /* * If we can't free the sysctl tree, oh well... */ @@ -1003,11 +1005,10 @@ xpt_print(periph->path, "can't remove sysctl context\n"); } - cam_periph_unlock(periph); disk_destroy(softc->disk); callout_drain(&softc->sendordered_c); + free(softc, M_DEVBUF); cam_periph_lock(periph); - free(softc, M_DEVBUF); } static void -- John Baldwin