From patchwork Wed Feb 5 22:09:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Srivatsa S. Bhat" X-Patchwork-Id: 3591981 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AE97EC02DC for ; Wed, 5 Feb 2014 22:16:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D9FE02012B for ; Wed, 5 Feb 2014 22:16:17 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E69F3200E8 for ; Wed, 5 Feb 2014 22:16:16 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBAl5-0008JF-7Z; Wed, 05 Feb 2014 22:15:51 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBAky-0004BM-CV; Wed, 05 Feb 2014 22:15:44 +0000 Received: from e28smtp03.in.ibm.com ([122.248.162.3]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBAks-00048c-Fa for linux-arm-kernel@lists.infradead.org; Wed, 05 Feb 2014 22:15:40 +0000 Received: from /spool/local by e28smtp03.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Feb 2014 03:45:15 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp03.in.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 6 Feb 2014 03:45:14 +0530 Received: from d28relay05.in.ibm.com (d28relay05.in.ibm.com [9.184.220.62]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id 67EA0394005A for ; Thu, 6 Feb 2014 03:45:14 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s15MFGMX4784472 for ; Thu, 6 Feb 2014 03:45:16 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s15MFCf7015852 for ; Thu, 6 Feb 2014 03:45:14 +0530 Received: from srivatsabhat.in.ibm.com ([9.79.225.33]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s15MF9Ta015612; Thu, 6 Feb 2014 03:45:10 +0530 From: "Srivatsa S. Bhat" Subject: [PATCH 29/51] arm64, debug-monitors: Fix CPU hotplug callback registration To: paulus@samba.org, oleg@redhat.com, rusty@rustcorp.com.au, peterz@infradead.org, tglx@linutronix.de, akpm@linux-foundation.org Date: Thu, 06 Feb 2014 03:39:58 +0530 Message-ID: <20140205220957.19080.79200.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20140205220251.19080.92336.stgit@srivatsabhat.in.ibm.com> References: <20140205220251.19080.92336.stgit@srivatsabhat.in.ibm.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14020522-3864-0000-0000-00000C4709E9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140205_171539_094490_77D64EFE X-CRM114-Status: GOOD ( 14.36 ) X-Spam-Score: -4.7 (----) Cc: ego@linux.vnet.ibm.com, walken@google.com, linux@arm.linux.org.uk, Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, "Srivatsa S. Bhat" , tj@kernel.org, Russell King , paulmck@linux.vnet.ibm.com, mingo@kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Subsystems that want to register CPU hotplug callbacks, as well as perform initialization for the CPUs that are already online, often do it as shown below: get_online_cpus(); for_each_online_cpu(cpu) init_cpu(cpu); register_cpu_notifier(&foobar_cpu_notifier); put_online_cpus(); This is wrong, since it is prone to ABBA deadlocks involving the cpu_add_remove_lock and the cpu_hotplug.lock (when running concurrently with CPU hotplug operations). Instead, the correct and race-free way of performing the callback registration is: cpu_maps_update_begin(); for_each_online_cpu(cpu) init_cpu(cpu); /* Note the use of the double underscored version of the API */ __register_cpu_notifier(&foobar_cpu_notifier); cpu_maps_update_done(); Fix the debug-monitors code in arm64 by using this latter form of callback registration. Cc: Catalin Marinas Cc: Will Deacon Cc: Russell King Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Srivatsa S. Bhat --- arch/arm64/kernel/debug-monitors.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c index 636ba8b..959a16b 100644 --- a/arch/arm64/kernel/debug-monitors.c +++ b/arch/arm64/kernel/debug-monitors.c @@ -155,12 +155,16 @@ static struct notifier_block os_lock_nb = { static int debug_monitors_init(void) { + cpu_maps_update_begin(); + /* Clear the OS lock. */ smp_call_function(clear_os_lock, NULL, 1); clear_os_lock(NULL); /* Register hotplug handler. */ - register_cpu_notifier(&os_lock_nb); + __register_cpu_notifier(&os_lock_nb); + + cpu_maps_update_done(); return 0; } postcore_initcall(debug_monitors_init);