From owner-freebsd-current@FreeBSD.ORG Fri Aug 14 16:41:55 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 B2693106568D for ; Fri, 14 Aug 2009 16:41:55 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 6D7378FC3D for ; Fri, 14 Aug 2009 16:41:55 +0000 (UTC) Received: from fledge.watson.org (fledge.watson.org [65.122.17.41]) by cyrus.watson.org (Postfix) with ESMTPS id 0A70346B1A; Fri, 14 Aug 2009 12:41:55 -0400 (EDT) Date: Fri, 14 Aug 2009 17:41:54 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Andrew Gallatin In-Reply-To: <4A857D16.9070403@cs.duke.edu> Message-ID: References: <4A857D16.9070403@cs.duke.edu> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-current@freebsd.org 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 16:41:55 -0000 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). Robert N M Watson Computer Laboratory University of Cambridge > > From the eventhandler, I do: > > fake_unit = -1; > i = clone_create(&mx_clones, &mx_cdevsw, &fake_unit, cdev, 0); > > if (i) { > /* need to allocate a new /dev/mx_fake.%d device node */ > *cdev = make_dev(&mx_cdevsw, unit2minor(fake_unit), > UID_ROOT, GID_WHEEL, > mode, "mx_fake.%d", fake_unit); > } > > This has worked fine from 5.x through 7.x, > but in 8.x, the /dev/mx_fake.* devices persist after > unload. If anything attempts to access them, the machine > falls over (trace appended). > > 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). > > What changed between 7.x and 8 with respect to device cloning? > > BTW, is there any easier option now in 8.x? > > Thanks, > > Drew > > Fatal trap 12: page fault while in kernel mode > cpuid = 0; apic id = 00 > fault virtual address = 0xffffffff81528a64 > fault code = supervisor read data, page not present > instruction pointer = 0x20:0xffffffff8052f009 > stack pointer = 0x28:0xffffff8018a75730 > frame pointer = 0x28:0xffffff8018a757a0 > code segment = base 0x0, limit 0xfffff, type 0x1b > = DPL 0, pres 1, long 1, def32 0, gran 1 > processor eflags = interrupt enabled, resume, IOPL = 0 > current process = 18087 (cat) > [thread pid 18087 tid 100061 ] > Stopped at devfs_open+0x69: testb $0x4,0x4(%rax) > db> bt > Tracing pid 18087 tid 100061 td 0xffffff000188bab0 > devfs_open() at devfs_open+0x69 > VOP_OPEN_APV() at VOP_OPEN_APV+0x44 > vn_open_cred() at vn_open_cred+0x2f4 > kern_openat() at kern_openat+0x179 > syscall() at syscall+0x28f > Xfast_syscall() at Xfast_syscall+0xd0 > --- syscall (5, FreeBSD ELF64, open), rip = 0x8007272ac, rsp = > 0x7fffffffe0d8, rbp = 0 --- > db> > Tracing pid 18087 tid 100061 td 0xffffff000188bab0 > devfs_open() at devfs_open+0x69 > VOP_OPEN_APV() at VOP_OPEN_APV+0x44 > vn_open_cred() at vn_open_cred+0x2f4 > kern_openat() at kern_openat+0x179 > syscall() at syscall+0x28f > Xfast_syscall() at Xfast_syscall+0xd0 > --- syscall (5, FreeBSD ELF64, open), rip = 0x8007272ac, rsp = > 0x7fffffffe0d8, rbp = 0 --- > _______________________________________________ > 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" >