From owner-svn-src-all@FreeBSD.ORG Fri Oct 24 15:28:20 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6685A106567A; Fri, 24 Oct 2008 15:28:20 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from palm.hoeg.nl (unknown [IPv6:2001:7b8:613:100::211]) by mx1.freebsd.org (Postfix) with ESMTP id 00D768FC26; Fri, 24 Oct 2008 15:28:20 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: by palm.hoeg.nl (Postfix, from userid 1000) id 930931D10F; Fri, 24 Oct 2008 17:28:18 +0200 (CEST) Date: Fri, 24 Oct 2008 17:28:18 +0200 From: Ed Schouten To: John Baldwin Message-ID: <20081024152818.GI6808@hoeg.nl> References: <200810231911.m9NJBisd064280@svn.freebsd.org> <200810231555.06892.jhb@freebsd.org> <20081024045012.GD6808@hoeg.nl> <200810241036.10595.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="fckbADODYWZD5TdN" Content-Disposition: inline In-Reply-To: <200810241036.10595.jhb@freebsd.org> User-Agent: Mutt/1.5.18 (2008-05-17) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184208 - head/sys/dev/uart X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Oct 2008 15:28:20 -0000 --fckbADODYWZD5TdN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * John Baldwin wrote: > On Friday 24 October 2008 12:50:12 am Ed Schouten wrote: > > * John Baldwin 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 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--