From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D464BC4167B for ; Mon, 11 Dec 2023 14:16:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343885AbjLKOP7 (ORCPT ); Mon, 11 Dec 2023 09:15:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344384AbjLKOPK (ORCPT ); Mon, 11 Dec 2023 09:15:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93B756A64 for ; Mon, 11 Dec 2023 06:00:20 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5810C433CB; Mon, 11 Dec 2023 14:00:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702303220; bh=ImSzezOf75I4eufWZaDerJJPQeZ5Bf89zUZ1j+HNsIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RLcEY3ZCg69d6MMEGA3QaFQwoWLqwW/G/4A2Qe/PBord+KXSHbp6KOTqDouw3GDbG 6iIfVJJKOWGzthQXfykxukD4WaIMeMsfA2PTNx6EneN+tztrDLXI+ahQt+XYbQ8NPw ZIBoO9ae4HY8bN2Rjm/2WX/MTX2j2SB/Fq3K82VPQH6/M9jBoBJFhcS/9k3ggNFFej +FmEhEGdFA8iODWMg9ToQBphObPMUAc9HuA5PQvaVEE6ohZbzsxrJG0PHCXdg1rPr/ iX3XzX1Z22scws7EikOFDI3pxXbpL5N2Bnlzgy83/bpcdJIBQsd9Km0n0M3MyK/Oc4 dkJqKYVMMKYhw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Stefan Wiehler , Huacai Chen , Thomas Bogendoerfer , Sasha Levin , chenhuacai@kernel.org, peterz@infradead.org, jiaxun.yang@flygoat.com, tglx@linutronix.de, linux-mips@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 15/19] mips/smp: Call rcutree_report_cpu_starting() earlier Date: Mon, 11 Dec 2023 08:57:49 -0500 Message-ID: <20231211135908.385694-15-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231211135908.385694-1-sashal@kernel.org> References: <20231211135908.385694-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.142 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Wiehler [ Upstream commit 55702ec9603ebeffb15e6f7b113623fe1d8872f4 ] rcutree_report_cpu_starting() must be called before clockevents_register_device() to avoid the following lockdep splat triggered by calling list_add() when CONFIG_PROVE_RCU_LIST=y: WARNING: suspicious RCU usage ... ----------------------------- kernel/locking/lockdep.c:3680 RCU-list traversed in non-reader section!! other info that might help us debug this: RCU used illegally from offline CPU! rcu_scheduler_active = 1, debug_locks = 1 no locks held by swapper/1/0. ... Call Trace: [] show_stack+0x64/0x158 [] dump_stack_lvl+0x90/0xc4 [] __lock_acquire+0x1404/0x2940 [] lock_acquire+0x14c/0x448 [] _raw_spin_lock_irqsave+0x50/0x88 [] clockevents_register_device+0x60/0x1e8 [] r4k_clockevent_init+0x220/0x3a0 [] start_secondary+0x50/0x3b8 raw_smp_processor_id() is required in order to avoid calling into lockdep before RCU has declared the CPU to be watched for readers. See also commit 29368e093921 ("x86/smpboot: Move rcu_cpu_starting() earlier"), commit de5d9dae150c ("s390/smp: move rcu_cpu_starting() earlier") and commit 99f070b62322 ("powerpc/smp: Call rcu_cpu_starting() earlier"). Signed-off-by: Stefan Wiehler Reviewed-by: Huacai Chen Signed-off-by: Thomas Bogendoerfer Signed-off-by: Sasha Levin --- arch/mips/kernel/smp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index 1986d13094100..a8d2f5f200784 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -333,10 +333,11 @@ early_initcall(mips_smp_ipi_init); */ asmlinkage void start_secondary(void) { - unsigned int cpu; + unsigned int cpu = raw_smp_processor_id(); cpu_probe(); per_cpu_trap_init(false); + rcutree_report_cpu_starting(cpu); mips_clockevent_init(); mp_ops->init_secondary(); cpu_report(); @@ -348,7 +349,6 @@ asmlinkage void start_secondary(void) */ calibrate_delay(); - cpu = smp_processor_id(); cpu_data[cpu].udelay_val = loops_per_jiffy; set_cpu_sibling_map(cpu); -- 2.42.0