From owner-p4-projects@FreeBSD.ORG Fri Apr 21 02:30:08 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 21E7716A403; Fri, 21 Apr 2006 02:30:08 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B40EA16A402; Fri, 21 Apr 2006 02:30:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1E7A143D49; Fri, 21 Apr 2006 02:30:07 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from zion.baldwin.cx (zion.baldwin.cx [192.168.0.7]) (authenticated bits=0) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k3L2U6ww019253; Thu, 20 Apr 2006 22:30:06 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: John Birrell Date: Thu, 20 Apr 2006 22:27:46 -0400 User-Agent: KMail/1.8.3 References: <200604202154.k3KLs0BB022204@repoman.freebsd.org> In-Reply-To: <200604202154.k3KLs0BB022204@repoman.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200604202227.47757.jhb@freebsd.org> X-Virus-Scanned: ClamAV 0.87.1/1411/Thu Apr 20 18:23:28 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx Cc: Perforce Change Reviews Subject: Re: PERFORCE change 95729 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: Fri, 21 Apr 2006 02:30:08 -0000 On Thursday 20 April 2006 05:54 pm, John Birrell wrote: > http://perforce.freebsd.org/chv.cgi?CH=3D95729 > > Change 95729 by jb@jb_freebsd2 on 2006/04/20 21:53:46 > > Use macros to translate Solaris kmem_zalloc(), kmem_alloc() and > kmem_free() calls into their FreeBSD equivalents. This turns out to > be a neat way to port their code. > > Most memory allocations in this driver occur with one or more > mutex/es locked. Since dtrace is part of a released product, I'm > porting this on the assumption that the locking strategy works. > With witness enabled, I can't have it downgrade a M_WAITOK call > to a M_NOWAIT call just because it thinks it's a not a good idea > to sleep with locks held. For this code, we need to do that and > we can't afford to fail because the thing that we might be trying > to trace is the low memory situation. We might not be too > successful, but we need to try. Anyway... that's why the mutexes > are initialised with M_NOWITNESS. This is because FreeBSD mutexes !=3D Solaris mutexes. You may or may not e= nd up=20 with arbitrary panics and deadlocks if the malloc() actually blocks. You could use an sx(9) instead and just use sx_xlock() and sx_xunlock() which w= ill=20 be safe to hold across a blocking malloc(). =2D-=20 John Baldwin =A0<>< =A0http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" =A0=3D =A0http://www.FreeBSD.org