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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5CFBC388F7 for ; Thu, 29 Oct 2020 02:11:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B30F20747 for ; Thu, 29 Oct 2020 02:11:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603937485; bh=uhOhRHxQVfGw7MyAyAJTdGF3H9kCy/1BltY5AjTtSN0=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:List-ID: From; b=s6emfsIs01JOHSTY/EByxFOwuDJbFPR+Wez6QTB1H3Um6H+dDXwxeKHGycZu7U9XT oRR2RB28edQeBEq029Qgrt/2cwgcLyHmg2qXTtFdDJhCAQjrGna8yg/krrsrZEhUeB 6J3xJNEXUhfjxHjIvCUofoQ2N2DV3eQEJoukdoFk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729694AbgJ2CLX (ORCPT ); Wed, 28 Oct 2020 22:11:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:35446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726934AbgJ1VhX (ORCPT ); Wed, 28 Oct 2020 17:37:23 -0400 Received: from paulmck-ThinkPad-P72.home (50-39-104-11.bvtn.or.frontiernet.net [50.39.104.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F04F624827; Wed, 28 Oct 2020 20:59:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603918763; bh=uhOhRHxQVfGw7MyAyAJTdGF3H9kCy/1BltY5AjTtSN0=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=loooxR5XyCI1oAjmIJHBwJpYv3LJvTxBzAr3RNF9wwefMD6/PYs7CotHJqnLyHWfP iJWhdiBHD8kIx56QNV6L8kXzavPKJe0TMhRs3XZhpvdyH+xqG7bUw64lnu5IOM7ejT MMYu3qltUG0hDSkGZwhklk03zwVcULaE3bL3uyxI= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id A1C2935229CE; Wed, 28 Oct 2020 13:59:22 -0700 (PDT) Date: Wed, 28 Oct 2020 13:59:22 -0700 From: "Paul E. McKenney" To: Qian Cai Cc: Peter Zijlstra , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] powerpc/smp: Move rcu_cpu_starting() earlier Message-ID: <20201028205922.GF3249@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20201028182334.13466-1-cai@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201028182334.13466-1-cai@redhat.com> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 28, 2020 at 02:23:34PM -0400, Qian Cai wrote: > The call to rcu_cpu_starting() in start_secondary() is not early enough > in the CPU-hotplug onlining process, which results in lockdep splats as > follows: > > WARNING: suspicious RCU usage > ----------------------------- > kernel/locking/lockdep.c:3497 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: > dump_stack+0xec/0x144 (unreliable) > lockdep_rcu_suspicious+0x128/0x14c > __lock_acquire+0x1060/0x1c60 > lock_acquire+0x140/0x5f0 > _raw_spin_lock_irqsave+0x64/0xb0 > clockevents_register_device+0x74/0x270 > register_decrementer_clockevent+0x94/0x110 > start_secondary+0x134/0x800 > start_secondary_prolog+0x10/0x14 > > This is avoided by moving the call to rcu_cpu_starting up near the > beginning of the start_secondary() function. Note that the > raw_smp_processor_id() is required in order to avoid calling into > lockdep before RCU has declared the CPU to be watched for readers. > > Link: https://lore.kernel.org/lkml/160223032121.7002.1269740091547117869.tip-bot2@tip-bot2/ > Signed-off-by: Qian Cai Acked-by: Paul E. McKenney > --- > arch/powerpc/kernel/smp.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index 3c6b9822f978..8c2857cbd960 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -1393,13 +1393,14 @@ static void add_cpu_to_masks(int cpu) > /* Activate a secondary processor. */ > void start_secondary(void *unused) > { > - unsigned int cpu = smp_processor_id(); > + unsigned int cpu = raw_smp_processor_id(); > > mmgrab(&init_mm); > current->active_mm = &init_mm; > > smp_store_cpu_info(cpu); > set_dec(tb_ticks_per_jiffy); > + rcu_cpu_starting(cpu); > preempt_disable(); > cpu_callin_map[cpu] = 1; > > -- > 2.28.0 >