From owner-freebsd-current@FreeBSD.ORG Fri Aug 14 19:33:03 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C8DF010656A3; Fri, 14 Aug 2009 19:33:03 +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 533E28FC65; Fri, 14 Aug 2009 19:33:03 +0000 (UTC) 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 n7EJWsVN047411 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 14 Aug 2009 22:32:55 +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.3/8.14.3) with ESMTP id n7EJWsmS071886; Fri, 14 Aug 2009 22:32:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id n7EJWsCu071885; Fri, 14 Aug 2009 22:32:54 +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: Fri, 14 Aug 2009 22:32:54 +0300 From: Kostik Belousov To: Andrew Gallatin Message-ID: <20090814193254.GO1884@deviant.kiev.zoral.com.ua> References: <4A857D16.9070403@cs.duke.edu> <4A85B9CD.4050802@cs.duke.edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="+MpzSEZXRO9YNlvm" Content-Disposition: inline In-Reply-To: <4A85B9CD.4050802@cs.duke.edu> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,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: freebsd-current@freebsd.org, Robert Watson Subject: Re: clone_cleanup() doesn't X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Aug 2009 19:33:04 -0000 --+MpzSEZXRO9YNlvm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 14, 2009 at 03:23:57PM -0400, Andrew Gallatin wrote: > Robert Watson wrote: > >On Fri, 14 Aug 2009, Andrew Gallatin wrote: > > > >>I've been porting a closed-source driver to FreeBSD 8 from FreeBSD=20 > >>5/6/7. It use the dev_clone() eventhandler to mimic linux-like open=20 > >>semantics (for linux binary compat). > > > >No particular experience with unloading cloning stuff, but have you=20 > >noticed that in 8.x we now have per-file descriptor device state? This= =20 > >is often the semantics people actually want, rather than cloning. See= =20 > >devfs_set_cdevpriv(9) for details -- there are several synthetic devices= =20 > >in the tree that use it now (although some of them do too much=20 > >error-checking, and should assert rather than return errors, I think). >=20 > Unfortunately, I think I still need device cloning. The linux semantics > are to open /dev/mx0, then call an ioctl to set the device private > state. This gets set (in linux) in the "struct file *" ->private_data > field. So multiple processes can open /dev/mx0, and they all have > different private data. This is exactly what you get with cdevpriv. You open a single device node, and driver attaches a private data to the file descriptor. >=20 > FWIW: >=20 > >>I'm assuming these files are lingering because clone_cleanup() > >>(called at device detach) is not cleaning up these lingering > >>device nodes. I've tried writing a dtrace script to trace > >>clone_cleanup. But since that happens from device detach, > >>dtrace doesn't work (blocks driver unload). I've also tried > >>setting a breakpoint in ddb(), but the breakpoint seems to > >>be ignored (other breakpoints work fine, which is odd). >=20 > I think ddb wasn't working because my kernel sources didn't quite > match my running kernel. After a kernel & module rebuild, I can watch > clone_cleanup(), and I see destroy_devl() get called. > It calls devfs_destroy(), as well. >=20 > The interesting thing is that if I run devd -D -d, and watch the > events scroll by, I see the destruction of a device with a > null name. Eg: >=20 > Processing event '!system=3DDEVFS subsystem=3DCDEV type=3DDESTROY cdev=3D' > Pushing table > setting system=3DDEVFS > setting subsystem=3DCDEV > setting type=3DDESTROY > setting cdev=3D > Processing notify event > <...> >=20 > If I do the same thing on 7.2, I see: >=20 > Processing event '!system=3DDEVFS subsystem=3DCDEV type=3DDESTROY cdev=3D= mx_fake.0' > Pushing table > setting system=3DDEVFS > setting subsystem=3DCDEV > setting type=3DDESTROY > setting cdev=3Dmx_fake.0 > Processing notify event >=20 > So I wonder if the node is not getting removed because its > name has gotten mangled somehow... >=20 > Drew > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" --+MpzSEZXRO9YNlvm Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkqFu+YACgkQC3+MBN1Mb4hgJQCeLacbCni2Cyjn1sZGnn8trxTo FmQAn3JdMLNj64jOna1h/1o4OvREIN9K =WYqr -----END PGP SIGNATURE----- --+MpzSEZXRO9YNlvm--