From owner-p4-projects Wed Apr 17 10:29:14 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5C99F37B404; Wed, 17 Apr 2002 10:28:53 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mail.speakeasy.net (mail12.speakeasy.net [216.254.0.212]) by hub.freebsd.org (Postfix) with ESMTP id 1BE8437B417 for ; Wed, 17 Apr 2002 10:28:46 -0700 (PDT) Received: (qmail 15030 invoked from network); 17 Apr 2002 17:28:45 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) by mail12.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 17 Apr 2002 17:28:45 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.11.6/8.11.6) with ESMTP id g3HHSiv81321; Wed, 17 Apr 2002 13:28:45 -0400 (EDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.2 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <200204171559.g3HFxnJ05061@freefall.freebsd.org> Date: Wed, 17 Apr 2002 13:27:48 -0400 (EDT) From: John Baldwin To: Robert Watson Subject: RE: PERFORCE change 9913 for review Cc: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 17-Apr-2002 Robert Watson wrote: > http://people.freebsd.org/~peter/p4db/chv.cgi?CH=9913 > > Change 9913 by rwatson@rwatson_tislabs on 2002/04/17 08:59:13 > > Remove use of an SX lock to protect the MAC policy chain. Instead, > use a mutex to protect the list in addition to a busy count. > Read-only consumers of the list (such as policy evaluation entry > points) will lock the mutex, increment the busy count, and release > the lock, prevent long-term holding of a lock and interference > with lock orders (as well as permitting recursion). When done, > they'll grab the lock, decrement the busy count, and release it. > Exclusive consumers, such as those registering and unregistering > policies, grab the mutex, check that the busy count is zero, > and return EBUSY if it is. They then hold the mutex for the > duration of the list modification, as well as the entry points for > module initialization and shutdown. It may be eventually we need > two classes of busy to avoid that. > > Note: no waiting occurs if the list is busy and exclusive access > is required. This means that kldloading a module can fail with > EBUSY if a policy check is occurring simultaneously. As Giant > gets pushed down, this will become an issue. Eventually, a CV > should be used to wake up consumers waiting on exclusive access > so that this does not occur. > > This commit gets rid of the various lock order warnings concerning > the MAC policy lock. So basically you just reinvented sx locks but they don't get checked for lock order reversals. If possible, I think you should go back to using sx locks but find out where the reversal is occuring and fix that. You can use a sx_try_xlock() to handle the EBUSY case. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message