Date: Fri, 14 Aug 2009 22:32:54 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: Andrew Gallatin <gallatin@cs.duke.edu> Cc: freebsd-current@freebsd.org, Robert Watson <rwatson@freebsd.org> Subject: Re: clone_cleanup() doesn't Message-ID: <20090814193254.GO1884@deviant.kiev.zoral.com.ua> In-Reply-To: <4A85B9CD.4050802@cs.duke.edu> References: <4A857D16.9070403@cs.duke.edu> <alpine.BSF.2.00.0908141737370.82989@fledge.watson.org> <4A85B9CD.4050802@cs.duke.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
--+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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090814193254.GO1884>