From patchwork Fri Mar 9 18:21:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 10271599 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE86E60236 for ; Fri, 9 Mar 2018 18:22:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC9C729E60 for ; Fri, 9 Mar 2018 18:22:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A07BD29FA4; Fri, 9 Mar 2018 18:22:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3B23B29F84 for ; Fri, 9 Mar 2018 18:22:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=D1NqWlOUYvNL4bwy/MYCSBrPJ/lsooRX/pHxHEvsSOI=; b=F/O5O2u45GtHpd xWVsywSXKfivtKafq8qGKgaz2cKRiMxs5K8uPPkT2UkbcKFTyuVg/csR6R3g0YSze83FesKIvnFVp jCT8EQhmOPXtkkoNNpAWjncE1ppz6mqrrFIkEV3rzolit0QMrA0DUHe0nvONFO1JQcC5hSYppkQPu FMro0F1PU4g7fcHMO5ZSGvrPv9Yrsc5XoG1ucaDQVulTYulhihAwGuFf5f2SqUzbPqKUcAw6kKqU8 JkARgNN1zE3MARLJan/fsanrBqhYd0E4UMfhOYkEr4HXm5Nwc5+/j97M4ll5+uVNa907uIncqs8Aq A5tWuDWs7mZoX2yd/Xew==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euMeX-0004nj-3m; Fri, 09 Mar 2018 18:22:01 +0000 Received: from galois.linutronix.de ([2a01:7a0:2:106d:700::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euMeS-0004lo-E8 for linux-arm-kernel@lists.infradead.org; Fri, 09 Mar 2018 18:21:58 +0000 Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1euMeB-0004l9-EX; Fri, 09 Mar 2018 19:21:39 +0100 Date: Fri, 9 Mar 2018 19:21:39 +0100 From: Sebastian Andrzej Siewior To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: smp: Move clear_tasks_mm_cpumask() call to __cpu_die() Message-ID: <20180309182139.gnyed3n34skwceqk@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180223 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180309_102156_644471_1E9727D5 X-CRM114-Status: GOOD ( 11.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: philipp@peloton-tech.com, Sekhar Nori , Russell King , Steven Rostedt , Austin Schuh , Thomas Gleixner Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Grygorii Strashko Suspending a CPU on a RT kernel results in the following backtrace: | Disabling non-boot CPUs ... | BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:917 | in_atomic(): 1, irqs_disabled(): 128, pid: 18, name: migration/1 | INFO: lockdep is turned off. | irq event stamp: 122 | hardirqs last enabled at (121): [] _raw_spin_unlock_irqrestore+0x88/0x90 | hardirqs last disabled at (122): [] _raw_spin_lock_irq+0x28/0x5c | CPU: 1 PID: 18 Comm: migration/1 Tainted: G W 4.1.4-rt3-01046-g96ac8da #204 | Hardware name: Generic DRA74X (Flattened Device Tree) | [] (unwind_backtrace) from [] (show_stack+0x20/0x24) | [] (show_stack) from [] (dump_stack+0x88/0xdc) | [] (dump_stack) from [] (___might_sleep+0x198/0x2a8) | [] (___might_sleep) from [] (rt_spin_lock+0x30/0x70) | [] (rt_spin_lock) from [] (find_lock_task_mm+0x9c/0x174) | [] (find_lock_task_mm) from [] (clear_tasks_mm_cpumask+0xb4/0x1ac) | [] (clear_tasks_mm_cpumask) from [] (__cpu_disable+0x98/0xbc) | [] (__cpu_disable) from [] (take_cpu_down+0x1c/0x50) | [] (take_cpu_down) from [] (multi_cpu_stop+0x11c/0x158) | [] (multi_cpu_stop) from [] (cpu_stopper_thread+0xc4/0x184) | [] (cpu_stopper_thread) from [] (smpboot_thread_fn+0x18c/0x324) | [] (smpboot_thread_fn) from [] (kthread+0xe8/0x104) | [] (kthread) from [] (ret_from_fork+0x14/0x3c) | CPU1: shutdown The root cause of above backtrace is task_lock() which takes a sleeping lock on -RT. To fix the issue, move clear_tasks_mm_cpumask() call from __cpu_disable() to __cpu_die() which is called on the thread which is asking for a target CPU to be shutdown. In addition, this change restores CPU hotplug functionality on ARM CPU1 can be unplugged/plugged many times. Signed-off-by: Grygorii Strashko Cc: Steven Rostedt Cc: Cc: Sekhar Nori Cc: Austin Schuh Cc: Cc: Russell King Link: http://lkml.kernel.org/r/1441995683-30817-1-git-send-email-grygorii.strashko@ti.com Signed-off-by: Thomas Gleixner [bigeasy: slighty edited the commit message] Signed-off-by: Sebastian Andrzej Siewior --- arch/arm/kernel/smp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -236,8 +236,6 @@ int __cpu_disable(void) flush_cache_louis(); local_flush_tlb_all(); - clear_tasks_mm_cpumask(cpu); - return 0; } @@ -255,6 +253,7 @@ void __cpu_die(unsigned int cpu) } pr_debug("CPU%u: shutdown\n", cpu); + clear_tasks_mm_cpumask(cpu); /* * platform_cpu_kill() is generally expected to do the powering off * and/or cutting of clocks to the dying CPU. Optionally, this may