From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 11 18:13:44 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D768E106589B; Mon, 11 Oct 2010 18:13:44 +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 A75438FC15; Mon, 11 Oct 2010 18:13: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 4EA8E46B35; Mon, 11 Oct 2010 14:13:44 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 400D08A01D; Mon, 11 Oct 2010 14:13:43 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Mon, 11 Oct 2010 12:11:37 -0400 User-Agent: KMail/1.13.5 (FreeBSD/7.3-CBSD-20100819; KDE/4.4.5; amd64; ; ) References: <4CAE092A.60905@freebsd.org> In-Reply-To: <4CAE092A.60905@freebsd.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201010111211.37993.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Mon, 11 Oct 2010 14:13:43 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.96.3 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.9 required=4.2 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bigwig.baldwin.cx Cc: Matthew Fleming , Andriy Gapon Subject: Re: generic_stop_cpus: prevent parallel execution 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: Mon, 11 Oct 2010 18:13:44 -0000 On Thursday, October 07, 2010 1:53:46 pm Andriy Gapon wrote: > > Here is patch that applies the technique from panic() to generic_stop_cpus() to > prevent its parallel execution on multiple CPUs: > http://people.freebsd.org/~avg/generic_stop_cpus.diff > > In theory this could lead to two CPUs stopping each other and everyone else, and > thus a total system halt. > > Also, in theory, we should have some smarter locking here, because two (or more > CPUs) could be stopping unrelated sets of CPUs. But in practice, it seems, this > function is only used to stop "all other" CPUs. Unless I overlooked other usages, > that is. > > Additionally, I took this opportunity to make amd64-specific suspend_cpus() > function use generic_stop_cpus() instead of rolling out essentially duplicate > code. I couldn't see any reason no to consolidate, but perhaps I missed something. > > Big thanks to Matthew and his employer for the idea and example. One note. Use 'cpu_spinwait()' in the inner loop waiting for 'stopping_cpu' to change. -- John Baldwin