From patchwork Mon Jun 20 10:14:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 896682 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5KAFCWK018924 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 20 Jun 2011 10:15:33 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QYbVY-0004XA-3b; Mon, 20 Jun 2011 10:15:04 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QYbVX-0005P4-Pi; Mon, 20 Jun 2011 10:15:03 +0000 Received: from [2002:4e20:1eda::1] (helo=caramon.arm.linux.org.uk) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QYbVU-0005Oi-KK for linux-arm-kernel@lists.infradead.org; Mon, 20 Jun 2011 10:15:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=caramon; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=Ql7b/hPFDOzZ4jKym84vEz6Y7WfV5NyA46kgr0cJync=; b=I6Bvi8GTum3rMYWIDQ9TLI10EYzvtwIorWsqTVWb9GQ+E3OtclQHiEVkwHYniNPyq9DWMIDIbcmg7N6QVhDuILrka4l3d0ZWRHuGXzVbZWrorfoE4r1RopJe/r1+fhZ4TgaFv285Q7+lWpKp/e8uvE9PIQpVnE6od0UeD8wXpSA=; Received: from n2100.arm.linux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]) by caramon.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1QYbVA-0000p9-JQ; Mon, 20 Jun 2011 11:14:41 +0100 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.72) (envelope-from ) id 1QYbV9-0000jU-9C; Mon, 20 Jun 2011 11:14:39 +0100 Date: Mon, 20 Jun 2011 11:14:38 +0100 From: Russell King - ARM Linux To: Santosh Shilimkar Subject: Re: [RFC PATCH] ARM: smp: Fix the CPU hotplug race with scheduler. Message-ID: <20110620101438.GD2082@n2100.arm.linux.org.uk> References: <1308561839-18407-1-git-send-email-santosh.shilimkar@ti.com> <20110620095053.GA2082@n2100.arm.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110620095053.GA2082@n2100.arm.linux.org.uk> User-Agent: Mutt/1.5.19 (2009-01-05) X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110620_061501_258732_230D1D70 X-CRM114-Status: GOOD ( 22.78 ) X-Spam-Score: 1.2 (+) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS Cc: Peter Zijlstra , Thomas Gleixner , linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 20 Jun 2011 10:15:33 +0000 (UTC) On Mon, Jun 20, 2011 at 10:50:53AM +0100, Russell King - ARM Linux wrote: > On Mon, Jun 20, 2011 at 02:53:59PM +0530, Santosh Shilimkar wrote: > > The current ARM CPU hotplug code suffers from couple of race conditions > > in CPU online path with scheduler. > > The ARM CPU hotplug code doesn't wait for hot-plugged CPU to be marked > > active as part of cpu_notify() by the CPU which brought it up before > > enabling interrupts. > > Hmm, why not just move the set_cpu_online() call before notify_cpu_starting() > and add the wait after the set_cpu_online() ? Actually, the race is caused by the CPU being marked online (and therefore available for the scheduler) but not yet active (the CPU asking this one to boot hasn't run the online notifiers yet.) This, I feel, is a fault of generic code. If the CPU is not ready to have processes scheduled on it (because migration is not initialized) then we shouldn't be scheduling processes on the new CPU yet. In any case, this should close the window by ensuring that we don't receive an interrupt in the online-but-not-active case. Can you please test? arch/arm/kernel/smp.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 344e52b..e34d750 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -318,9 +318,15 @@ asmlinkage void __cpuinit secondary_start_kernel(void) smp_store_cpu_info(cpu); /* - * OK, now it's safe to let the boot CPU continue + * OK, now it's safe to let the boot CPU continue. Wait for + * the CPU migration code to notice that the CPU is online + * before we continue. */ + local_irq_disable(); set_cpu_online(cpu, true); + while (!cpumask_test_cpu(cpu, cpu_active_mask)) + cpu_relax(); + local_irq_enable(); /* * OK, it's off to the idle thread for us