From owner-p4-projects@FreeBSD.ORG Thu Aug 7 18:43:06 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0F9C11065670; Thu, 7 Aug 2008 18:43:06 +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 C75421065683; Thu, 7 Aug 2008 18:43:05 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (skuns.zoral.com.ua [91.193.166.194]) by mx1.freebsd.org (Postfix) with ESMTP id 201548FC14; Thu, 7 Aug 2008 18:43:04 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m77IRb1M070600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 7 Aug 2008 21:27:37 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m77IRaSI008952; Thu, 7 Aug 2008 21:27:36 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2/Submit) id m77IRalP008929; Thu, 7 Aug 2008 21:27:36 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 7 Aug 2008 21:27:36 +0300 From: Kostik Belousov To: John Baldwin Message-ID: <20080807182736.GX97161@deviant.kiev.zoral.com.ua> References: <200808031737.m73HbJO8065922@repoman.freebsd.org> <200808071218.40578.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="NFhhVVeDTkyNvWHh" Content-Disposition: inline In-Reply-To: <200808071218.40578.jhb@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.93.3, clamav-milter version 0.93.3 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: Ed Schouten , Perforce Change Reviews , Robert Watson Subject: Re: PERFORCE change 146544 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, 07 Aug 2008 18:43:06 -0000 --NFhhVVeDTkyNvWHh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 07, 2008 at 12:18:40PM -0400, John Baldwin wrote: > On Sunday 03 August 2008 01:46:38 pm Robert Watson wrote: > >=20 > > On Sun, 3 Aug 2008, Ed Schouten wrote: > >=20 > > > http://perforce.freebsd.org/chv.cgi?CH=3D146544 > > > > > > Change 146544 by ed@ed_flippo on 2008/08/03 17:36:53 > > > > > > Add a counter to store the number of null modem devices. > >=20 > > I've seen similar constructs in lots of drivers, and it's basically an= =20 > unsafe=20 > > construct because the deregister is non-atomic with respect to the busy= =20 > check.=20 > > I wonder if, instead, we should use a mutex to protect the count, and s= et it=20 > > to some value to deny future allocations, such as -1, once the ebusy ch= eck=20 > is=20 > > past... Even that is unideal, though. >=20 > Yes, you basically need to set a flag of some sort to disable cloning, th= en go=20 > tear down the clone handler. And, yes, you probably should just use a mu= tex=20 > for this (there are tricky games one could play with atomic ops, but give= n=20 > how rare clone and detach happen, it isn't worth the code complexity). I answered to Ed on the channel, the right incantation sequence is: 1. remove clone eventhandler; 2. call drain_dev_clone_events() to move past the point where new clones may be created; 3. do the destroy_dev() as needed; 4. if code ever called destroy_dev_sched(), call destroy_dev_drain(&csw). --NFhhVVeDTkyNvWHh Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkibPpcACgkQC3+MBN1Mb4gTZQCgiIIvXHgeg/xfXEPuHI1pwpvc assAoM6R6kV1jpkGsEZzbOiORS9utmSQ =udKS -----END PGP SIGNATURE----- --NFhhVVeDTkyNvWHh--