From owner-freebsd-current@FreeBSD.ORG Thu Nov 17 21:02:04 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 3081D1065673; Thu, 17 Nov 2011 21:02:04 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-pz0-f44.google.com (mail-pz0-f44.google.com [209.85.210.44]) by mx1.freebsd.org (Postfix) with ESMTP id DE8DC8FC08; Thu, 17 Nov 2011 21:02:03 +0000 (UTC) Received: by pzk33 with SMTP id 33so7198675pzk.3 for ; Thu, 17 Nov 2011 13:02:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=g2/bSSisEi1VRmd2dbONUFes9u9R4O7kSG/PUHp7PKk=; b=AxxgghNMcIZLZy+6olnAqDy2mbgy+AExqzjB/cLI+3vWjxiMSUMXLJlLoZmtv5LLnt bGUu7MpkPcdH+GeeG0gAoQmaTjA6Zipz5/yqMSbHuAjt7jN2hvF/FQfbAOEXGW+FGbjj ABn7NASzrSM7tDxNWpN7KPjbKfSFjeUUdJ0HY= MIME-Version: 1.0 Received: by 10.68.33.134 with SMTP id r6mr2229482pbi.76.1321563723370; Thu, 17 Nov 2011 13:02:03 -0800 (PST) Sender: mdf356@gmail.com Received: by 10.68.56.97 with HTTP; Thu, 17 Nov 2011 13:02:03 -0800 (PST) In-Reply-To: References: <20111113083215.GV50300@deviant.kiev.zoral.com.ua> <201111171137.18663.jhb@freebsd.org> <4EC53D1B.4000308@FreeBSD.org> <201111171409.37629.jhb@freebsd.org> <4EC563BB.60209@FreeBSD.org> Date: Thu, 17 Nov 2011 13:02:03 -0800 X-Google-Sender-Auth: U_DQZcUjUPejYz1lF3mhFsd3gRI Message-ID: From: mdf@FreeBSD.org To: Attilio Rao Content-Type: text/plain; charset=ISO-8859-1 Cc: Kostik Belousov , Alexander Motin , freebsd-current@freebsd.org, Andriy Gapon 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, 17 Nov 2011 21:02:04 -0000 On Thu, Nov 17, 2011 at 12:54 PM, Attilio Rao wrote: > 2011/11/17 Andriy Gapon : >> BTW, it is my opinion that we really should not let the debugger code call >> mi_switch for any reason. > > Yes, I agree with this, this is why the sched_bind() in boot() is > broken (immagine calling things like doadump from KDB. KDB right now > can be thought as a first cut of this patch because it does disable > the CPUs when entering the context, thus, the bug here is that if you > stop all CPUs including CPU0 and later on you want bind on it you are > death). Another patch related to this area we have at $WORK: #if defined(SMP) - /* - * Bind us to CPU 0 so that all shutdown code runs there. Some - * systems don't shutdown properly (i.e., ACPI power off) if we - * run on another processor. - */ - thread_lock(curthread); - sched_bind(curthread, 0); - thread_unlock(curthread); - KASSERT(PCPU_GET(cpuid) == 0, ("%s: not running on cpu 0", __func__)); + /* + * sched_bind can't be done reliably inside of panic. cpu_reset() will + * rebind us in any case, more reliably. + */ + if (panicstr == NULL) { + /* + * Bind us to CPU 0 so that all shutdown code runs there. Some + * systems don't shutdown properly (i.e., ACPI power off) if we + * run on another processor. + */ + thread_lock(curthread); + sched_bind(curthread, 0); + thread_unlock(curthread); + KASSERT(PCPU_GET(cpuid) == 0, ("boot: not running on cpu 0")); + } #endif /* We're in the process of rebooting. */ rebooting = 1; Cheers, matthew