From patchwork Fri May 4 11:29: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: 10380353 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 9F7F36038F for ; Fri, 4 May 2018 11:32:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9028E27F93 for ; Fri, 4 May 2018 11:32:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8453328372; Fri, 4 May 2018 11:32:59 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI 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 D067D28161 for ; Fri, 4 May 2018 11:32:58 +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:Date:Subject:To :From: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=PZMdAmyAcgt/OeeNJZPvkXeGfwrCpfViYvaqRsaK/cQ=; b=Fs3lKkK9NtYP5K m22j4W48BgGofS7jG0/ftlPz8D3n10aurSX4iAF49yGELo2nj6Eipp30xvn+wZkM7sYfYx+YYW579 WPO9waFS6EhvaHUI1c8Bnh0IjZEMkc33jcYaRURdEcEVwUBTa8evOQioam8DGetOKtlpDTcT/AEDV ftmT6Oz7ccXNMaDkB/y4FpRBl5uYgV+kcUBsaGwOHju+5lsM0kQDwqrgxvkzkckIyjwAWsnTtaCTM fG2JmADJbrdV+cla/c5fI18fR4N48Y8/OpeL0XJwCxjFZWtDHqbN3AyLAjJctSpz5SUc1w71QHDF8 TRkW+vobbfCkd0fwseJQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fEYxC-0000iX-7W; Fri, 04 May 2018 11:32:46 +0000 Received: from galois.linutronix.de ([2a01:7a0:2:106d:700::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fEYua-0006tY-2n for linux-arm-kernel@lists.infradead.org; Fri, 04 May 2018 11:30:10 +0000 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1fEYuJ-0002DJ-FA; Fri, 04 May 2018 13:29:47 +0200 From: Sebastian Andrzej Siewior To: linux-arm-kernel@lists.infradead.org Subject: [PATCH REPOST] ARM: smp: Move clear_tasks_mm_cpumask() call to __cpu_die() Date: Fri, 4 May 2018 13:29:39 +0200 Message-Id: <20180504112939.25493-1-bigeasy@linutronix.de> X-Mailer: git-send-email 2.17.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180504_043004_321655_FD4D5257 X-CRM114-Status: GOOD ( 12.42 ) 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: Russell King , tglx@linutronix.de, Grygorii Strashko , Sekhar Nori , Sebastian Andrzej Siewior 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: Cc: Sekhar Nori 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