Skip site navigation (1)Skip section navigation (2)
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>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
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:
> > 
> > On Sun, 3 Aug 2008, Ed Schouten wrote:
> > 
> > > http://perforce.freebsd.org/chv.cgi?CH=146544
> > >
> > > Change 146544 by ed@ed_flippo on 2008/08/03 17:36:53
> > >
> > > 	Add a counter to store the number of null modem devices.
> > 
> > I've seen similar constructs in lots of drivers, and it's basically an 
> unsafe 
> > construct because the deregister is non-atomic with respect to the busy 
> check. 
> > I wonder if, instead, we should use a mutex to protect the count, and set it 
> > to some value to deny future allocations, such as -1, once the ebusy check 
> is 
> > past...  Even that is unideal, though.
> 
> Yes, you basically need to set a flag of some sort to disable cloning, then go 
> tear down the clone handler.  And, yes, you probably should just use a mutex 
> for this (there are tricky games one could play with atomic ops, but given 
> 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).

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (FreeBSD)

iEYEARECAAYFAkibPpcACgkQC3+MBN1Mb4gTZQCgiIIvXHgeg/xfXEPuHI1pwpvc
assAoM6R6kV1jpkGsEZzbOiORS9utmSQ
=udKS
-----END PGP SIGNATURE-----
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080807182736.GX97161>