From owner-freebsd-arch@FreeBSD.ORG Tue Jul 20 19:09:08 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1DAEA16A4CE; Tue, 20 Jul 2004 19:09:08 +0000 (GMT) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id C050543D31; Tue, 20 Jul 2004 19:09:07 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from [192.168.0.200] ([192.168.0.200]) (authenticated bits=0) by pooker.samsco.org (8.12.11/8.12.10) with ESMTP id i6KJFDrf059769; Tue, 20 Jul 2004 13:15:13 -0600 (MDT) (envelope-from scottl@samsco.org) Message-ID: <40FD6DC6.5030907@samsco.org> Date: Tue, 20 Jul 2004 13:08:54 -0600 From: Scott Long User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7) Gecko/20040702 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Brian Fundakowski Feldman References: <75243.1090347623@critter.freebsd.dk> <20040720183213.GC1009@green.homeunix.org> In-Reply-To: <20040720183213.GC1009@green.homeunix.org> X-Enigmail-Version: 0.84.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=0.0 required=3.8 tests=none autolearn=no version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on pooker.samsco.org cc: arch@freebsd.org cc: Poul-Henning Kamp Subject: Re: kldunload DIAGNOSTIC idea... X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jul 2004 19:09:08 -0000 Brian Fundakowski Feldman wrote: > On Tue, Jul 20, 2004 at 08:20:23PM +0200, Poul-Henning Kamp wrote: > >>I'm pulling hair out trying to make it guaranteed safe to unload device >>driver modules, and the major pain here is to make sure there is no >>thread stuck somewhere inside the code. >> >>That gave me the idea for a simple little DIAGNOSTIC check for kldunload: >>run through the proc/thread table and look for any thread with an >>instruction counter inside the range of pages we are going to unload. >> >>Any takers ? > > > You mean any thread with a stack trace that includes an instruction > counter inside those pages, don't you? > This is better than phk's suggestion since you can have module code that calls out to another part of the system and blocks. Still, it's not 100% perfect. There are all sorts of APIs out there that do async callbacks, and it really should be up to the driver to track these things. Scott