From owner-freebsd-arch@FreeBSD.ORG Sun Aug 28 09:30:19 2011 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C1429106566C; Sun, 28 Aug 2011 09:30:19 +0000 (UTC) (envelope-from hselasky@freebsd.org) Received: from swip.net (mailfe07.c2i.net [212.247.154.194]) by mx1.freebsd.org (Postfix) with ESMTP id 1BC328FC0A; Sun, 28 Aug 2011 09:30:18 +0000 (UTC) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.1 cv=We2KpSpXIp7zua8olfHtbA6oPL2p8ijoExYxXUNIRvU= c=1 sm=1 a=SvYTsOw2Z4kA:10 a=ni9ZY7ZFbhgA:10 a=dBRESv0yCI8A:10 a=8nJEP1OIZ-IA:10 a=CL8lFSKtTFcA:10 a=i9M/sDlu2rpZ9XS819oYzg==:17 a=Ixxbx_S_ukA7SaRvA8wA:9 a=wPNLvfGTeEIA:10 a=i9M/sDlu2rpZ9XS819oYzg==:117 Received: from [188.126.198.129] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe07.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 171642795; Sun, 28 Aug 2011 11:30:16 +0200 Received-SPF: softfail receiver=mailfe07.swip.net; client-ip=188.126.198.129; envelope-from=hselasky@freebsd.org From: Hans Petter Selasky To: freebsd-arch@freebsd.org Date: Sun, 28 Aug 2011 11:27:44 +0200 User-Agent: KMail/1.13.5 (FreeBSD/8.2-STABLE; KDE/4.4.5; amd64; ; ) References: <4E53986B.5000804@FreeBSD.org> <4E5A099F.4060903@FreeBSD.org> In-Reply-To: <4E5A099F.4060903@FreeBSD.org> X-Face: *nPdTl_}RuAI6^PVpA02T?$%Xa^>@hE0uyUIoiha$pC:9TVgl.Oq, NwSZ4V"|LR.+tj}g5 %V,x^qOs~mnU3]Gn; cQLv&.N>TrxmSFf+p6(30a/{)KUU!s}w\IhQBj}[g}bj0I3^glmC( :AuzV9:.hESm-x4h240C`9=w MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201108281127.44696.hselasky@freebsd.org> Cc: Andriy Gapon Subject: Re: skipping locks, mutex_owned, usb X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Aug 2011 09:30:19 -0000 On Sunday 28 August 2011 11:25:51 Andriy Gapon wrote: > on 23/08/2011 15:09 Andriy Gapon said the following: > > This "XXX cludge" [sic] pattern is scattered around a few functions in > > the ukbd code and perhaps other usb code: > > func() > > { > > > > if (!mtx_owned(&Giant)) { > > > > mtx_lock(&Giant); > > > > func(); > > mtx_unlock(&Giant); > > > > return; > > > > } > > > > // etc ... > > > > } > > Ohhh, nothing seems simple with the USB code: > > /* make sure that the BUS mutex is not locked */ > drop_bus = 0; > while (mtx_owned(&xroot->udev->bus->bus_mtx)) { > mtx_unlock(&xroot->udev->bus->bus_mtx); > drop_bus++; > } > > /* make sure that the transfer mutex is not locked */ > drop_xfer = 0; > while (mtx_owned(xroot->xfer_mtx)) { > mtx_unlock(xroot->xfer_mtx); > drop_xfer++; > } > > So many unconventional tricks. Similar code is used in the DROP_GIANT and PICKUP_GIANT macros. You might want to check all references to mtx_owned() in the kernel, and make a set of exceptions for post-panic code execution. --HPS