From owner-freebsd-current@FreeBSD.ORG Tue Sep 1 14:16:36 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 B3CFA1065693; Tue, 1 Sep 2009 14:16:36 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 732E88FC1E; Tue, 1 Sep 2009 14:16:36 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 1FAC546B03; Tue, 1 Sep 2009 10:16:36 -0400 (EDT) Received: from jhbbsd.hudson-trading.com (unknown [209.249.190.8]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 226D08A040; Tue, 1 Sep 2009 10:16:35 -0400 (EDT) From: John Baldwin To: freebsd-current@freebsd.org Date: Tue, 1 Sep 2009 09:55:33 -0400 User-Agent: KMail/1.9.7 References: <20090822115958.f93fcf29.ubm.freebsd@gmail.com> <20090831222650.45b6c806.ubm@u-boot-man.de> <3bbf2fe10908311331k3e871898tc36a9846651cc53@mail.gmail.com> In-Reply-To: <3bbf2fe10908311331k3e871898tc36a9846651cc53@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200909010955.33747.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Tue, 01 Sep 2009 10:16:35 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=4.2 tests=AWL,BAYES_00,RDNS_NONE autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: Attilio Rao , Marc UBM Subject: Re: panic: apic_free_vector: Thread already bound. 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: Tue, 01 Sep 2009 14:16:36 -0000 On Monday 31 August 2009 4:31:50 pm Attilio Rao wrote: > 2009/8/31 Marc UBM : > > On Mon, 24 Aug 2009 16:31:05 -0400 > > John Baldwin wrote: > > > >> On Saturday 22 August 2009 5:59:58 am Marc UBM wrote: > >> > > >> > Hiho! :-) > >> > > >> > I'm seeing above panic in the final stages of the shutdown process. > >> > Coredump is available, bt as follows, textdump attached. > >> > > >> > > >> > FreeBSD hamstor 8.0-BETA2 FreeBSD 8.0-BETA2 #14: Wed Aug 19 22:43:17 > >> > CEST 2009 oni0@hamstor:/usr/obj/usr/src/sys/HAMSTOR amd64 > >> > > >> > > >> > (kgdb) bt > >> > #0 doadump () at pcpu.h:223 > >> > #1 0xffffffff801b561c in db_fncall (dummy1=Variable "dummy1" is not > >> > #available. > >> > ) at /usr/src/sys/ddb/db_command.c:548 > >> > #2 0xffffffff801b5951 in db_command (last_cmdp=0xffffffff808594a0, > >> > #cmd_table=Variable "cmd_table" is not available. > >> > ) at /usr/src/sys/ddb/db_command.c:445 > >> > #3 0xffffffff801b5ba0 in db_command_loop () > >> > #at /usr/src/sys/ddb/db_command.c:498 4 0xffffffff801b7b69 in > >> > #db_trap (type=Variable "type" is not available. > >> > ) at /usr/src/sys/ddb/db_main.c:229 > >> > #5 0xffffffff8038d775 in kdb_trap (type=3, code=0, > >> > #tf=0xffffff8000017760) at /usr/src/sys/kern/subr_kdb.c:535 6 > >> > #0xffffffff8060e170 in trap (frame=0xffffff8000017760) > >> > #at /usr/src/sys/amd64/amd64/trap.c:611 7 0xffffffff805f3b23 in > >> > #calltrap () at /usr/src/sys/amd64/amd64/exception.S:224 8 > >> > #0xffffffff8038d94d in kdb_enter (why=0xffffffff80681954 "panic", > >> > #msg=0xa
) at cpufunc.h:63 9 > >> > #0xffffffff8035e04b in panic (fmt=Variable "fmt" is not available. > >> > ) at /usr/src/sys/kern/kern_shutdown.c:562 > >> > #10 0xffffffff805fafbb in apic_free_vector (apic_id=Variable > >> > #"apic_id" is not available. > >> > ) at /usr/src/sys/amd64/amd64/local_apic.c:995 > >> > #11 0xffffffff805f7560 in intr_remove_handler (cookie=Variable > >> > #"cookie" is not available. > >> > ) at /usr/src/sys/amd64/amd64/intr_machdep.c:203 > >> > #12 0xffffffff806250d4 in hpt_shutdown_vbus > >> > #(vbus_ext=0xffffff8000254000, howto=Variable "howto" is not > >> > #available. > >> > ) at /usr/src/sys/dev/hptrr/hptrr_osm_bsd.c:361 > >> > #13 0xffffffff8035da8b in boot (howto=16392) > >> > #at /usr/src/sys/kern/kern_shutdown.c:419 14 0xffffffff8035e126 in > >> > #reboot (td=Variable "td" is not available. > >> > ) at /usr/src/sys/kern/kern_shutdown.c:173 > >> > #15 0xffffffff8060dbba in syscall (frame=0xffffff8000017c80) > >> > #at /usr/src/sys/amd64/amd64/trap.c:982 16 0xffffffff805f3e01 in > >> > #Xfast_syscall () at /usr/src/sys/amd64/amd64/exception.S:373 17 > >> > #0x000000000040892c in ?? () > >> > Previous frame inner to this frame (corrupt stack?) > >> > > >> > frame #12 & #13 make me suspect the hptrr driver (again :-)), but > >> > I'm not sure. > >> > >> Ah, any driver shutting off its interrupt handler during shutdown > >> would actually trigger this. The hptrr driver doesn't really need to > >> do this during shutdown, but I think we don't want to panic in this > >> case. Unfortunately we don't currently have a "in_shutdown" type of > >> global flag that we can check in apic_free_vector() to not worry > >> about the thread already being bound. > > > > Is there any chance this fix might make it into 8.0? It's not a real > > problem for me since I can just power-off by force, but I imagine it > > might be a real pita for people who only have remote access and want > > to reboot, etc. > > Maybe we can ship 8 with a printf() instrad than a panic()? Actually, it looks like 'rebooting' is what we want. Try this: --- //depot/vendor/freebsd/src/sys/amd64/amd64/local_apic.c 2009/08/14 21:10:13 +++ //depot/user/jhb/acpipci/amd64/amd64/local_apic.c 2009/09/01 13:54:23 @@ -990,18 +990,21 @@ * we don't lose an interrupt delivery race. */ td = curthread; - thread_lock(td); - if (sched_is_bound(td)) - panic("apic_free_vector: Thread already bound.\n"); - sched_bind(td, apic_cpuid(apic_id)); - thread_unlock(td); + if (!rebooting) { + thread_lock(td); + if (sched_is_bound(td)) + panic("apic_free_vector: Thread already bound.\n"); + sched_bind(td, apic_cpuid(apic_id)); + thread_unlock(td); + } mtx_lock_spin(&icu_lock); lapics[apic_id].la_ioint_irqs[vector - APIC_IO_INTS] = -1; mtx_unlock_spin(&icu_lock); - thread_lock(td); - sched_unbind(td); - thread_unlock(td); - + if (!rebooting) { + thread_lock(td); + sched_unbind(td); + thread_unlock(td); + } } /* Map an IDT vector (APIC) to an IRQ (interrupt source). */ --- //depot/vendor/freebsd/src/sys/i386/i386/local_apic.c 2009/08/14 21:10:13 +++ //depot/user/jhb/acpipci/i386/i386/local_apic.c 2009/09/01 13:53:14 @@ -994,18 +994,21 @@ * we don't lose an interrupt delivery race. */ td = curthread; - thread_lock(td); - if (sched_is_bound(td)) - panic("apic_free_vector: Thread already bound.\n"); - sched_bind(td, apic_cpuid(apic_id)); - thread_unlock(td); + if (!rebooting) { + thread_lock(td); + if (sched_is_bound(td)) + panic("apic_free_vector: Thread already bound.\n"); + sched_bind(td, apic_cpuid(apic_id)); + thread_unlock(td); + } mtx_lock_spin(&icu_lock); lapics[apic_id].la_ioint_irqs[vector - APIC_IO_INTS] = -1; mtx_unlock_spin(&icu_lock); - thread_lock(td); - sched_unbind(td); - thread_unlock(td); - + if (!rebooting) { + thread_lock(td); + sched_unbind(td); + thread_unlock(td); + } } /* Map an IDT vector (APIC) to an IRQ (interrupt source). */ -- John Baldwin