Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp945566pxb; Thu, 5 Nov 2020 18:17:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwjTuIqqlNvvRYj0J3GqC1tepm5Xb6cLC9z1nBFkk3w/+h4ZfnTyJm41vg9vt5dAdI5tPh X-Received: by 2002:a05:6402:1c9b:: with SMTP id cy27mr5919904edb.161.1604629070196; Thu, 05 Nov 2020 18:17:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604629070; cv=none; d=google.com; s=arc-20160816; b=Z7Oiq4NwIIiLTnmIjWthT+h/HKuTCP/VIj4tKSy5HYAZ9HxAarPfcx2aO11BGE4g1p CF8YY9v8Q3CMnDYzHgY001GheGbvYDYO/WHoKUI2Q2QrBwyCoszjxBd58sRs5qHI2W0V Dn12uIQ/dt6a802B4LPEOFwFAeBcYy6jVEsF0Mo2yIFT+UkAfdFe+qKxAQuCNnIRrO/Q pTCKgkglPv2Y1HsvRAXB0/wGGRYn2nJym+UDQ+snshTDwj9tVvfxbwkmzDJo/MMawIUH pF2I/fgfBz2BhUeUe0SFuLaRFjI6z3rTXnSOGUHR9USL6Jmik92KKRO3PmO+kdCXXm34 t7qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=nMiau+jB2NAVadVlE4lIKx50BpAJxCRzjB9cxthbDzE=; b=rg5M9kGyeT4yB4Gd1Ts/g+PEoMbkPFszF3fwwl1USiM86F7b6C7oHSSdzCzY4ppRiA qUKdFj4XEV5GKqx9WdocoNnbSvTH4B7eHWjdQKuUyY9w9EvbezJlCDZutkBj2ZC53N1b HrZz1ALKmYmapB9jTFEJHPfPybatlIQe2fVtnIOaPdm18gPDIFzDBVhI6uGSB9ncZYcI 5FADS6P4vW/XQ4790WMcOUsU+PQqc3ACmm4wrzzyZbvMAqDUtUagfxWOMmsLBf6xDkrp s4DMhhn7QQy28digXD3DoMnr/Cn7VKac2LHXvtSJhVI/PbMHoBKNkp0xYTCW5ImLT4w1 Iisw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fORDaRHW; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si3795407ejo.726.2020.11.05.18.17.26; Thu, 05 Nov 2020 18:17:50 -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=@redhat.com header.s=mimecast20190719 header.b=fORDaRHW; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726225AbgKFCPd (ORCPT + 99 others); Thu, 5 Nov 2020 21:15:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:24577 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbgKFCPd (ORCPT ); Thu, 5 Nov 2020 21:15:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604628931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nMiau+jB2NAVadVlE4lIKx50BpAJxCRzjB9cxthbDzE=; b=fORDaRHW33bh4BgAjdK48BRdtrUCfocm+OLZxCKKs1FHePo6q0wgvsqK8tmKqg+TLzvO5Y lKkaqSmNvxzyuw9L+MfGTVgpG/hUhNqPjdm3dimpJwv/vKJi03U45U/PRPUtthWZTtd0x7 IMHQgPfn6mrxldH9NiOwsd696aLLe50= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-80-mjNetBekP4qbiEIJBGsy_A-1; Thu, 05 Nov 2020 21:15:27 -0500 X-MC-Unique: mjNetBekP4qbiEIJBGsy_A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 638308030B8; Fri, 6 Nov 2020 02:15:26 +0000 (UTC) Received: from ovpn-114-171.rdu2.redhat.com (ovpn-114-171.rdu2.redhat.com [10.10.114.171]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5BEA355794; Fri, 6 Nov 2020 02:15:25 +0000 (UTC) Message-ID: Subject: Re: [PATCH] arm64/smp: Move rcu_cpu_starting() earlier From: Qian Cai To: paulmck@kernel.org Cc: Will Deacon , catalin.marinas@arm.com, kernel-team@android.com, Peter Zijlstra , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Date: Thu, 05 Nov 2020 21:15:24 -0500 In-Reply-To: <20201105232813.GR3249@paulmck-ThinkPad-P72> 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> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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