Date: Thu, 7 Aug 2008 21:27:36 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: John Baldwin <jhb@freebsd.org> Cc: Ed Schouten <ed@freebsd.org>, Perforce Change Reviews <perforce@freebsd.org>, Robert Watson <rwatson@freebsd.org> Subject: Re: PERFORCE change 146544 for review Message-ID: <20080807182736.GX97161@deviant.kiev.zoral.com.ua> In-Reply-To: <200808071218.40578.jhb@freebsd.org> References: <200808031737.m73HbJO8065922@repoman.freebsd.org> <alpine.BSF.1.10.0808031845230.18760@fledge.watson.org> <200808071218.40578.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080807182736.GX97161>