From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 8 19:08:45 2010 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2FD631065775; Fri, 8 Oct 2010 19:08:45 +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 A339D8FC15; Fri, 8 Oct 2010 19:08:44 +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 48C9246B32; Fri, 8 Oct 2010 15:08:44 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 3FFBC8A04F; Fri, 8 Oct 2010 15:08:43 -0400 (EDT) From: John Baldwin To: freebsd-current@freebsd.org Date: Fri, 8 Oct 2010 15:01:18 -0400 User-Agent: KMail/1.13.5 (FreeBSD/7.3-CBSD-20100819; KDE/4.4.5; amd64; ; ) References: <4CAE0621.3070809@freebsd.org> In-Reply-To: <4CAE0621.3070809@freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201010081501.18870.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Fri, 08 Oct 2010 15:08:43 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: hackers@freebsd.org, Andriy Gapon Subject: Re: panic_cpu should be volatile X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Oct 2010 19:08:45 -0000 On Thursday, October 07, 2010 1:40:49 pm Andriy Gapon wrote: > > panic_cpu variable in kern_shutdown.c should be volatile otherwise it's cached in > a register in the innermost while-loop in this code (observed on amd64 with base > gcc and -O2): > if (panic_cpu != PCPU_GET(cpuid)) > while (atomic_cmpset_int(&panic_cpu, NOCPU, > PCPU_GET(cpuid)) == 0) > while (panic_cpu != NOCPU) > ; /* nothing */ > > The patch is here: > http://people.freebsd.org/~avg/panic_cpu.diff > > I also took a liberty to move the variable into the scope of panic() functions as > it doesn't seem to be useful outside of it. But this is not necessary, of course. Looks fine to me. -- John Baldwin