From owner-freebsd-hackers@FreeBSD.ORG Thu Oct 7 17:53:49 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 2581D1065695; Thu, 7 Oct 2010 17:53:49 +0000 (UTC) (envelope-from avg@freebsd.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 383988FC25; Thu, 7 Oct 2010 17:53:47 +0000 (UTC) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id UAA18721; Thu, 07 Oct 2010 20:53:46 +0300 (EEST) (envelope-from avg@freebsd.org) Message-ID: <4CAE092A.60905@freebsd.org> Date: Thu, 07 Oct 2010 20:53:46 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.9) Gecko/20100920 Lightning/1.0b2 Thunderbird/3.1.4 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Matthew Fleming Subject: 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: Thu, 07 Oct 2010 17:53:49 -0000 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. -- Andriy Gapon