Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp989943pxb; Thu, 5 Nov 2020 20:09:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxSFlIm0shycK5mSEV0DAMORXBD5p0P8EhL8o3OaWrUpQqpa0bV1Amm1YBk61ljpfTvVLxM X-Received: by 2002:aa7:d1c6:: with SMTP id g6mr98423edp.130.1604635791626; Thu, 05 Nov 2020 20:09:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604635791; cv=none; d=google.com; s=arc-20160816; b=ecR/IUr7+ZY86lyapahF/RZrkhJ74enTzAMHUm1kRHhQGCifPd5EKE64bm3du8sC1M /NTlIBQ8KxWXyEGhZUSocYVpxk3DyZObpGONzpkfkASDFYN2RnxHaS79m27oEwhGd+PC xA6edCZkgqMBmEyuGC9z/izKSwjE2hJTtB2FNmxcY5656dV4kVlzi/Le7AumwAVrt8Xu jXKnrExpyCSrAkRXbjmZV7C2acpMKd8z0fApzxX18p3rVD4eFjdJM6/quB5bAxjBhMuE KL4y8OUqMUpJ57Dt7TgX73CkfOd+n+M1vvB+RlGvGBEpzthsfTM36eXdx6dI8o7UNy4R drJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=tpZ1tcUNaGidDynSH47/PvN0xyjwAIBeoGPa4Z8nJvM=; b=xT6VAAB/mYdmCaj6KfnHqEu/VPTqxlQSBUrOmvoVMc3ZgVx7YCh6Y+/mQ1gweGw8rg xQA11Op+29n6kmuaPOtpLek7HwF5Cbsnf3ZF4KQyz9wQ01bNT3LdUS9gmWSMrk4hX8QX TkLPHKaFm56UlVvZGMbUfo0UrznTA/0E22oyl1yX9a7dbJqiRN7aYRvYzQtRN7pH0PUS fNOpW0SURg+um40svu66AB0khwUP0YEHlpOT8s/Cw5jzM44Tymfi1BCsZnV07FVKVjie JNEV+49fdTQt/UCvrEoRl0onR4m5lqFXo2Sp2zbgfxZ1ImRkaEOmklS00EkF98PxDX3R NoMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="FzPXO/hX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si3334099ejd.641.2020.11.05.20.09.29; Thu, 05 Nov 2020 20:09:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="FzPXO/hX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725868AbgKFEHQ (ORCPT + 99 others); Thu, 5 Nov 2020 23:07:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:34808 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725616AbgKFEHQ (ORCPT ); Thu, 5 Nov 2020 23:07:16 -0500 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 31A292067C; Fri, 6 Nov 2020 04:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604635635; bh=x749VDOE0kRsPi7mKRGEx+ShORQkiqV8g3bkMLRGmYA=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=FzPXO/hXLo2O61wypPrvGlm4J7yTdOxZrOPySHQtj0r09Kz5DbOScDEkRU8rmJT3q ATsIMfbhMXAgj4Kh9/brSwZN521oFoSRhBiALAOh2eO96r5stAFy2JBXQ3C1q8uL7Y zsCz6RqfeL/VsJvEA1j/hZn8CzyOnyuUX/zglvx4= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id C9DC73522AAE; Thu, 5 Nov 2020 20:07:14 -0800 (PST) Date: Thu, 5 Nov 2020 20:07:14 -0800 From: "Paul E. McKenney" To: Qian Cai Cc: Will Deacon , catalin.marinas@arm.com, kernel-team@android.com, Peter Zijlstra , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] arm64/smp: Move rcu_cpu_starting() earlier Message-ID: <20201106040714.GS3249@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20201028182614.13655-1-cai@redhat.com> <160404559895.1777248.8248643695413627642.b4-ty@kernel.org> <20201105222242.GA8842@willie-the-truck> <3b4c324abdabd12d7bd5346c18411e667afe6a55.camel@redhat.com> <20201105232813.GR3249@paulmck-ThinkPad-P72> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 05, 2020 at 09:15:24PM -0500, Qian Cai wrote: > On Thu, 2020-11-05 at 15:28 -0800, Paul E. McKenney wrote: > > On Thu, Nov 05, 2020 at 06:02:49PM -0500, Qian Cai wrote: > > > On Thu, 2020-11-05 at 22:22 +0000, Will Deacon wrote: > > > > On Fri, Oct 30, 2020 at 04:33:25PM +0000, Will Deacon wrote: > > > > > On Wed, 28 Oct 2020 14:26:14 -0400, Qian Cai wrote: > > > > > > The call to rcu_cpu_starting() in secondary_start_kernel() 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!! > > > > > > > > > > > > [...] > > > > > > > > > > Applied to arm64 (for-next/fixes), thanks! > > > > > > > > > > [1/1] arm64/smp: Move rcu_cpu_starting() earlier > > > > > https://git.kernel.org/arm64/c/ce3d31ad3cac > > > > > > > > Hmm, this patch has caused a regression in the case that we fail to > > > > online a CPU because it has incompatible CPU features and so we park it > > > > in cpu_die_early(). We now get an endless spew of RCU stalls because the > > > > core will never come online, but is being tracked by RCU. So I'm tempted > > > > to revert this and live with the lockdep warning while we figure out a > > > > proper fix. > > > > > > > > What's the correct say to undo rcu_cpu_starting(), given that we cannot > > > > invoke the full hotplug machinery here? Is it correct to call > > > > rcutree_dying_cpu() on the bad CPU and then rcutree_dead_cpu() from the > > > > CPU doing cpu_up(), or should we do something else? > > > It looks to me that rcu_report_dead() does the opposite of > > > rcu_cpu_starting(), > > > so lift rcu_report_dead() out of CONFIG_HOTPLUG_CPU and use it there to > > > rewind, > > > Paul? > > > > Yes, rcu_report_dead() should do the trick. Presumably the earlier > > online-time CPU-hotplug notifiers are also unwound? > I don't think that is an issue here. cpu_die_early() set CPU_STUCK_IN_KERNEL, > and then __cpu_up() will see a timeout waiting for the AP online and then deal > with CPU_STUCK_IN_KERNEL according. Thus, something like this? I don't see > anything in rcu_report_dead() depends on CONFIG_HOTPLUG_CPU=y. If this works for the ARM folks, it seems like a reasonable approach to me. I cannot reasonably test this because not only do I not have an ARM system, I don't have a system on which a kernel can be built with CONFIG_HOTPLUG_CPU=n, so I must rely on others' testing. Thanx, Paul > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 09c96f57818c..10729d2d6084 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -421,6 +421,8 @@ void cpu_die_early(void) > > update_cpu_boot_status(CPU_STUCK_IN_KERNEL); > > + rcu_report_dead(cpu); > + > cpu_park_loop(); > } > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 2a52f42f64b6..bd04b09b84b3 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -4077,7 +4077,6 @@ void rcu_cpu_starting(unsigned int cpu) > smp_mb(); /* Ensure RCU read-side usage follows above initialization. */ > } > > -#ifdef CONFIG_HOTPLUG_CPU > /* > * The outgoing function has no further need of RCU, so remove it from > * the rcu_node tree's ->qsmaskinitnext bit masks. > @@ -4117,6 +4116,7 @@ void rcu_report_dead(unsigned int cpu) > rdp->cpu_started = false; > } > > +#ifdef CONFIG_HOTPLUG_CPU > /* > * The outgoing CPU has just passed through the dying-idle state, and we > * are being invoked from the CPU that was IPIed to continue the offline >