From owner-freebsd-arch@FreeBSD.ORG Tue Jul 20 19:07:54 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 C34B516A4CE; Tue, 20 Jul 2004 19:07:54 +0000 (GMT) Received: from freebee.digiware.nl (dsl390.iae.nl [212.61.63.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1FF9743D60; Tue, 20 Jul 2004 19:07:51 +0000 (GMT) (envelope-from wjw@withagen.nl) Received: from dual (dual [212.61.27.71]) by freebee.digiware.nl (8.12.10/8.12.10) with SMTP id i6KJ7nsD015845; Tue, 20 Jul 2004 21:07:49 +0200 (CEST) (envelope-from wjw@withagen.nl) Message-ID: <015b01c46e8c$d9d7eca0$471b3dd4@digiware.nl> From: "Willem Jan Withagen" To: "Brian Fundakowski Feldman" , "Poul-Henning Kamp" References: <20040720183213.GC1009@green.homeunix.org><75604.1090348797@critter.freebsd.dk> <20040720185236.GD1009@green.homeunix.org> Date: Tue, 20 Jul 2004 21:07:49 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 cc: arch@freebsd.org 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:07:54 -0000 > On Tue, Jul 20, 2004 at 08:39:57PM +0200, Poul-Henning Kamp wrote: > > In message <20040720183213.GC1009@green.homeunix.org>, Brian Fundakowski Feldma > > n writes: > > >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 ? Sounds like a tantalizing task, which would match with my (old) compiler knowledge. But I wonder if I know enough of the kernel internals to ever get it doing something usefull. > > > > > >You mean any thread with a stack trace that includes an instruction > > >counter inside those pages, don't you? > > > > That would require us to unwind the stack which I think is overkill > > for the purpose. > > > > The most likely case is that the thread is sleeping on something > > inside the kld so just checking the instruction pointer would be > > fine. > > > > Looking for sleep addresses inside the module might make sense too. > > It's probably not overkill -- at least in my experience most of the > time a driver is "doing something" it is sleeping, so the address > will be in mi_switch() or somewhere way out there. Sleep addresses > on dynamic data addresses are also a lot more common than sleep > addresses on static/code addresses. If someone is interested in > doign this, it would be very informative, especially if it could > catch sleeps, pending timeouts, pending callouts, etc. Ignorant, and without prejustice, I'd say: The major problem here would be to get the framework in place. Once that is available, it is glueing the principal code together, and whether it is an address, or a series of addresses from a stack-unwind. The later is only going to be more compute intensive. --WjW