From owner-freebsd-current@FreeBSD.ORG Thu Dec 1 20:42:27 2011 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 ECD5D1065680; Thu, 1 Dec 2011 20:42:27 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 0A9738FC18; Thu, 1 Dec 2011 20:42:26 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id WAA18409; Thu, 01 Dec 2011 22:42:25 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1RWDSb-0007kV-80; Thu, 01 Dec 2011 22:42:25 +0200 Message-ID: <4ED7E6B0.30400@FreeBSD.org> Date: Thu, 01 Dec 2011 22:42:24 +0200 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:8.0) Gecko/20111108 Thunderbird/8.0 MIME-Version: 1.0 To: John Baldwin References: <20111113083215.GV50300@deviant.kiev.zoral.com.ua> <201111211132.42119.jhb@freebsd.org> <4ED7B25E.8070002@FreeBSD.org> <201112011349.50502.jhb@freebsd.org> In-Reply-To: <201112011349.50502.jhb@freebsd.org> X-Enigmail-Version: undefined Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-current@FreeBSD.org Subject: Re: Stop scheduler on panic 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: Thu, 01 Dec 2011 20:42:28 -0000 on 01/12/2011 20:49 John Baldwin said the following: > On Thursday, December 01, 2011 11:59:10 am Andriy Gapon wrote: >> >> [cc list trimmed] >> >> on 21/11/2011 18:32 John Baldwin said the following: >>> On Friday, November 18, 2011 4:59:32 pm Andriy Gapon wrote: >>>> on 17/11/2011 23:38 John Baldwin said the following: >>>>> On Thursday, November 17, 2011 4:35:07 pm John Baldwin wrote: >>>>>> Hmmm, you could also make critical_exit() not perform deferred preemptions >>>>>> if SCHEDULER_STOPPED? That would fix the recursion and still let the >>>>>> preemption "work" when resuming from the debugger? >> >> >> Just to clarify, probably you are actually suggesting to not perform deferred >> preemptions if kdb_active == TRUE. Because that's where we get the recursion (via >> kdb_switch). >> >> I think that if we get into the mi_switch in a state where !kdb_active && >> SCHEDULER_STOPPED(), then we probably should just - I don't know - panic again? >> >> [the following is preserved for context] > > Hmmm. I'd be tempted to just ignore pending preemptions anytime > SCHEDULER_STOPPED() is true. If it's stopped for a reason other than being > in the debugger (e.g. panic), I'd rather make a best effort at getting a dump > than panic again. Yep, me too. It's just that I assumed that ending up at mi_switch in the panic thread/context meant that something had gone very wrong already. But I am not sure if this was a valid assumption. Returning to critical_exit, what do you think about the following patch? I guess that it could be committed independently of / before the SCHEDULER_STOPPED thing. commit ee3d1a04985e86911a68d854439ae8c5429b7bd5 Author: Andriy Gapon Date: Thu Dec 1 18:53:36 2011 +0200 critical_exit: ignore td_owepreempt if kdb_active calling mi_switch in such a context result in a recursion via kdb_switch diff --git a/sys/kern/kern_switch.c b/sys/kern/kern_switch.c index 93cbf7b..885dc22 100644 --- a/sys/kern/kern_switch.c +++ b/sys/kern/kern_switch.c @@ -200,7 +200,7 @@ critical_exit(void) if (td->td_critnest == 1) { td->td_critnest = 0; - if (td->td_owepreempt) { + if (td->td_owepreempt && !kdb_active) { td->td_critnest = 1; thread_lock(td); td->td_critnest--; Would it make sense wrap kdb_active check with __predict_false? -- Andriy Gapon