From owner-freebsd-arch@FreeBSD.ORG Wed Dec 7 17:04:27 2011 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2EBAA1065673; Wed, 7 Dec 2011 17:04:27 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lpp01m010-f54.google.com (mail-lpp01m010-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 48A588FC0A; Wed, 7 Dec 2011 17:04:25 +0000 (UTC) Received: by lagv3 with SMTP id v3so435897lag.13 for ; Wed, 07 Dec 2011 09:04:25 -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 :content-transfer-encoding; bh=E9zrRUEp5DEeTTKf4PwUo6guthOx1ZReH1BD2rtV28k=; b=vQgNUOR1JND5tB8XE/75W1evH/3nYu9EC5o7YYjXZbU9SyfIdJ/RxQpB9mFqyhbpxL 4uzUqas1L6Y09bsFo4E0vioQjETKmTys5BO2rhrZQnfQ7kZCgtF3q/KwAeMHnk975MLE UP2DlmxR1ymO3GX4VEQnjo/dvJnZ12rGsjaE0= MIME-Version: 1.0 Received: by 10.152.146.100 with SMTP id tb4mr12404786lab.0.1323277464964; Wed, 07 Dec 2011 09:04:24 -0800 (PST) Sender: asmrookie@gmail.com Received: by 10.152.21.104 with HTTP; Wed, 7 Dec 2011 09:04:23 -0800 (PST) In-Reply-To: <4EDF18AA.2070509@FreeBSD.org> References: <20111113083215.GV50300@deviant.kiev.zoral.com.ua> <4EDE8931.1080506@FreeBSD.org> <4EDF18AA.2070509@FreeBSD.org> Date: Wed, 7 Dec 2011 18:04:23 +0100 X-Google-Sender-Auth: 3VTSG5NIDt_2dVxzKFjRWiATR7w Message-ID: From: Attilio Rao To: Andriy Gapon Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Kostik Belousov , arch@freebsd.org, current@freebsd.org Subject: Re: Stop scheduler on panic X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Dec 2011 17:04:27 -0000 2011/12/7 Andriy Gapon : > on 07/12/2011 00:11 Attilio Rao said the following: >> I'd just change this check on panicstr: >> @@ -606,9 +603,13 @@ kdb_trap(int type, int code, struct trapframe *tf) >> =C2=A0 =C2=A0 =C2=A0 intr =3D intr_disable(); >> >> =C2=A0#ifdef SMP >> - =C2=A0 =C2=A0 other_cpus =3D all_cpus; >> - =C2=A0 =C2=A0 CPU_CLR(PCPU_GET(cpuid), &other_cpus); >> - =C2=A0 =C2=A0 stop_cpus_hard(other_cpus); >> + =C2=A0 =C2=A0 if (panicstr =3D=3D NULL) { >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 other_cpus =3D all_cpus; >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CPU_CLR(PCPU_GET(cpuid), &ot= her_cpus); >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 stop_cpus_hard(other_cpus); >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 did_stop_cpus =3D 1; >> + =C2=A0 =C2=A0 } else >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 did_stop_cpus =3D 0; >> >> to be SCHEDULER_STOPPED(). > > Makes sense. =C2=A0I will do this. > >> If you agree I can fix the kern_mutex, kern_sx and kern_rwlock parts >> and it should be done. > > Since I am not very familiar with the details of that code, I can not be = against > such a proposal :-) =C2=A0What Kostik did seemed quite reasonable to me, = but if that > can be further improved, then I am all for it. The following patch is a further add-on on Kostik's: http://www.freebsd.org/~attilio/scheduler_stopped.patch - Rework of mutex, rwlock and sxlock for a correct dealing of hard and fast paths - Protection of LOCK_PROFILING bits (missed also in my review) - Protection of WITNESS_SAVE/RESTORE because of Giant handling (missed also in my review) - Removal of gratuitous whitelines - Usage of SCHEDULER_STOPPED() in kdb check What do you think about it? I just test-compiled it with several combinations of LOCK_PROFILING and LOCK_DEBUG, but I didn't change the bulk of it thus it should be perfectly fine. If you like it I'd say to go for the commit asap. I wonder if someone tried to simulate a livelock and panic and thus verify that stoppcbs is correctly populated as expected (to be honest, this is one of the best features I'm interested into for this patch). Thanks, Attilio --=20 Peace can only be achieved by understanding - A. Einstein