Date: Fri, 24 Oct 2008 17:28:18 +0200 From: Ed Schouten <ed@80386.nl> To: John Baldwin <jhb@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184208 - head/sys/dev/uart Message-ID: <20081024152818.GI6808@hoeg.nl> In-Reply-To: <200810241036.10595.jhb@freebsd.org> References: <200810231911.m9NJBisd064280@svn.freebsd.org> <200810231555.06892.jhb@freebsd.org> <20081024045012.GD6808@hoeg.nl> <200810241036.10595.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--fckbADODYWZD5TdN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * John Baldwin <jhb@freebsd.org> wrote: > On Friday 24 October 2008 12:50:12 am Ed Schouten wrote: > > * John Baldwin <jhb@freebsd.org> wrote: > > > Perhaps have tty drivers sleep in detach until the tty is completely = gone? =20 > > > Either that or free the unit number in the tty layer when the tty is= =20 > > > abandoned. > >=20 > > Well, I could add a routine to the TTY layer that does that. The reason > > why the TTY layer is a little `lazy' with deallocating TTY unit numbers, > > is because I want to be absolutely sure processes agree they do not use > > the TTY (device name) anymore. > >=20 > > I'll see if I can add a sleepable tty_gone() routine one of these days. >=20 > I think what you want then is for the detach() routines to block until th= e tty=20 > is fully drained. This is similar to what we do for other places=20 > (ether_ifdetach() is supposed to sleep until the ifnet is completely=20 > unreferenced from userland for example (it may not fully ensure this yet,= but=20 > that is the way the driver should use the API, the driver can't possibly= =20 > close that sort of race in its own code). >=20 > Actually, detach() _needs_ to block because when you kldunload a driver, = once=20 > detach() returns the code segment for that module can be unmapped. If th= ere=20 > are threads in that driver's tty routines still then you can get kernel p= age=20 > faults. Yes. That's true, but the reason why I implemented the way it is right now, is because the current behaviour is *very* pleasant to implement things like pts(4). There is no blocking inside the close() path of a pseudo-terminal master device (which makes no sense) and the tsw_free routine just returns the unit number back to the unrhdr (see ptsdrv_free() in sys/kern/tty_pts.c). But as I said, I will add a routine which does this. Apart from that, drivers could already implement the sleeping themselves, by just sleeping on a conditional variable until tsw_free() has been called. But it's easier to provide a proper routine to do this. --=20 Ed Schouten <ed@80386.nl> WWW: http://80386.nl/ --fckbADODYWZD5TdN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkkB6ZIACgkQ52SDGA2eCwVeZwCff3wJ07yNXP0QVojAOzRzT2lM NxwAn2isRp1wAx4P7iw3mAeEhOhqCl5h =HfTL -----END PGP SIGNATURE----- --fckbADODYWZD5TdN--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081024152818.GI6808>