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
[-- Attachment #1 --] 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 > >>5/6/7. It use the dev_clone() eventhandler to mimic linux-like open > >>semantics (for linux binary compat). > > > >No particular experience with unloading cloning stuff, but have you > >noticed that in 8.x we now have per-file descriptor device state? This > >is often the semantics people actually want, rather than cloning. See > >devfs_set_cdevpriv(9) for details -- there are several synthetic devices > >in the tree that use it now (although some of them do too much > >error-checking, and should assert rather than return errors, I think). > > 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. > > FWIW: > > >>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). > > 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. > > 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: > > Processing event '!system=DEVFS subsystem=CDEV type=DESTROY cdev=' > Pushing table > setting system=DEVFS > setting subsystem=CDEV > setting type=DESTROY > setting cdev= > Processing notify event > <...> > > If I do the same thing on 7.2, I see: > > Processing event '!system=DEVFS subsystem=CDEV type=DESTROY cdev=mx_fake.0' > Pushing table > setting system=DEVFS > setting subsystem=CDEV > setting type=DESTROY > setting cdev=mx_fake.0 > Processing notify event > > So I wonder if the node is not getting removed because its > name has gotten mangled somehow... > > 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" [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkqFu+YACgkQC3+MBN1Mb4hgJQCeLacbCni2Cyjn1sZGnn8trxTo FmQAn3JdMLNj64jOna1h/1o4OvREIN9K =WYqr -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090814193254.GO1884>
