From owner-freebsd-current@FreeBSD.ORG Fri Aug 14 15:05:02 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 0C8B51065672 for ; Fri, 14 Aug 2009 15:05:02 +0000 (UTC) (envelope-from gallatin@cs.duke.edu) Received: from duke.cs.duke.edu (duke.cs.duke.edu [152.3.140.1]) by mx1.freebsd.org (Postfix) with ESMTP id C565D8FC43 for ; Fri, 14 Aug 2009 15:05:01 +0000 (UTC) Received: from [172.31.193.10] (cpe-069-134-110-200.nc.res.rr.com [69.134.110.200]) (authenticated bits=0) by duke.cs.duke.edu (8.14.2/8.14.2) with ESMTP id n7EF500k029357 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 14 Aug 2009 11:05:01 -0400 (EDT) X-DKIM: Sendmail DKIM Filter v2.8.3 duke.cs.duke.edu n7EF500k029357 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=cs.duke.edu; s=mail; t=1250262301; bh=AVgmBz45i2PX6D+ErZmYjKvHoOm7B3JIQ7bqN/p2xzQ=; h=Message-ID:Date:From:MIME-Version:To:Subject:Content-Type: Content-Transfer-Encoding; b=W9xnZOIghL+XObGt4gDrJn+eJo58yuFoKhaSvdoR7Je/H1x0Xo4ElAaBNZpDqeEhZ LGICYUBvHbZCyCOzCM0rUsZFCX8Z0napZLK9+clW1u++1Cv4JrJKhIjPSP8nXZJIaB m8fLsPHshK9bT7LD2GpQegq1SvoHriV+BvNI/Ooo= Message-ID: <4A857D16.9070403@cs.duke.edu> Date: Fri, 14 Aug 2009 11:04:54 -0400 From: Andrew Gallatin User-Agent: Thunderbird 2.0.0.22 (X11/20090608) MIME-Version: 1.0 To: freebsd-current@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: 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 15:05:02 -0000 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). 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 ---