From owner-freebsd-current@FreeBSD.ORG Fri Dec 2 04:36:46 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 0D88A106564A; Fri, 2 Dec 2011 04:36:46 +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 9DA978FC15; Fri, 2 Dec 2011 04:36:45 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) by cyrus.watson.org (Postfix) with ESMTPSA id 53E2846B09; Thu, 1 Dec 2011 23:36:45 -0500 (EST) Received: from John-Baldwins-MacBook-Air.local (c-68-36-150-83.hsd1.nj.comcast.net [68.36.150.83]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id D03B6B925; Thu, 1 Dec 2011 23:36:44 -0500 (EST) Message-ID: <4ED855E6.20207@FreeBSD.org> Date: Thu, 01 Dec 2011 23:36:54 -0500 From: John Baldwin User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Andriy Gapon References: <20111113083215.GV50300@deviant.kiev.zoral.com.ua> <201112011349.50502.jhb@freebsd.org> <4ED7E6B0.30400@FreeBSD.org> <201112011553.34432.jhb@freebsd.org> <4ED7F4BC.3080206@FreeBSD.org> In-Reply-To: <4ED7F4BC.3080206@FreeBSD.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 01 Dec 2011 23:36:44 -0500 (EST) 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: Fri, 02 Dec 2011 04:36:46 -0000 On 12/1/11 4:42 PM, Andriy Gapon wrote: > on 01/12/2011 22:53 John Baldwin said the following: >> On Thursday, December 01, 2011 3:42:24 pm Andriy Gapon wrote: >>> 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--; >> >> I think this is fine, but I'd probably change this to SCHEDULER_STOPPED() >> in the SCHEDULER_STOPPED() patch. > > I don't understand why... What if kdb is entered for some other reason, not > because of panic? In that case SCHEDULER_STOPPED() would be false, but it is > still possible to find a way into mi_switch. > > The SCHEDULER_STOPPED patch adds this: > @@ -428,6 +428,8 @@ mi_switch(int flags, struct thread *newtd) > */ > if (kdb_active) > kdb_switch(); > + if (SCHEDULER_STOPPED()) > + return; > if (flags& SW_VOL) { > td->td_ru.ru_nvcsw++; > td->td_swvoltick = ticks; Ah, ok (I had thought SCHEDULER_STOPPED was going to always be true when kdb was active). But I think these two changes should cover critical_exit() ok. -- John Baldwin