Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp42602lqc; Thu, 7 Mar 2024 09:45:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUyyZfLoKeHU36c1hgXnJcfQBcuR1fBefSm8XnnP1HEEi3UrSrueKvKINaEFPN1Z0L9+n8hz07fKwgHL6kIlj7FT8s7xkqO8ZKg481jYw== X-Google-Smtp-Source: AGHT+IFsHgRoCjYlrygMNXn4QqUeRrUjNEwaFGvYcFJouZBDfyHUNqRheKzV38cI8DqK5nLtD8Sh X-Received: by 2002:a17:906:1804:b0:a45:d17e:201c with SMTP id v4-20020a170906180400b00a45d17e201cmr1677198eje.54.1709833544155; Thu, 07 Mar 2024 09:45:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709833544; cv=pass; d=google.com; s=arc-20160816; b=n5XCvx2GceDbiYbIjxo1PDZxJTb1v9hWLgAw1Mfd/suHyHFtGuNHcRLUQ/4C9uNjkh mvFWYHkWcd9qpCpOYR1x6K/U5lmL7xanpl3rxTHDEhJI/GPfg66NzF72MEL9dSH0iakK vQ2saItsGLOO+XyWntmtH1CZYTCKL45t2z6sm+8SdcQxR2kOtwl+gSiQbb8Y3xk1E4g6 UyTp/KGn4SuvjMKrmQgI8ImqUgnaG7dduOTOOpcoMcdn/hCOT48EmtS6IZikulXDwy6g SzFFZlUDQ/DehRlu5cLQb4/YMzEYWMm3LXkBjZevZKqsZGKARssDaQTxvO2aTGNwmJpg 22Ew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=s4C66ycotp5Kj0El85+hjWGEDZEYsvCzOqKlZ28Mz68=; fh=KRyqRGT9BkJBMwB+d4kUKv/zURuM2B37X59KAeqDteU=; b=MgCxzjwiR/rSjr1uK6byFHpOvMhpS5iY7dF/uwA255e+rdBnVgYIvsFV175D8a9QAg 1gZlQjBPzLoLg/Svzy/GM5TUprcvJfsTXv17g8rHQLkvZzV5hS76yQ6JE4rNVktXd50b HUBeudORnXgwwa4QL3WcGH2tRDcROaH+C84RSXXWa8LhGOtEKVzgrRWrYvlhlJQ3oSaw Ik5bxoxEQuNFDIfNl8XMuxxR+1ZOHMZhNc6eEusMMUvucOMSkGOGNVZ/UtBM04C2+H2J 2+Sm5ULkCIvVYwamyfsu/SN6fVQelKmzuCk0L+yud/Nt9qrJnC9eeLcd8kFDcYQJcpzy w0PQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uiCSn3uK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-95968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95968-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x20-20020a170906135400b00a45ac365697si2481209ejb.433.2024.03.07.09.45.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 09:45:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uiCSn3uK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-95968-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95968-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D84241F214D9 for ; Thu, 7 Mar 2024 17:45:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D65F0130E37; Thu, 7 Mar 2024 17:45:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uiCSn3uK" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F348B12DDBA; Thu, 7 Mar 2024 17:45:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709833537; cv=none; b=ChOYYCKO45IfitYVwrVfSJin17wHUXwFEGpAkgpbFNvKj8IFdWYsyBzqDd67ar4oWBmpNrhwUbwH2iPpkOeYnMfpEQsrBWyZdhUTpc1HIsCXKD6tFIqedw3NDzqVKk6sV6Jl8GYdu9Q5RDbBtoNY95X7C2XPylzzzhGEbMbA6eY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709833537; c=relaxed/simple; bh=fmex7ycV6097BZ7cnW/vpknMTfZttQAd8IWkJXjDdCU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hAON2q1S79nMPvjr/s/yU8WfgPFoDOs2pecCBYj8e6Vf6iMQ2kCdQCRpIa3CNz7X0pLuS7oE8tWHFcQ9+PNthczQblx9AMiodH1hMVo7oR9tUK5aNli9NQCa87YzYbLPeMt8onHpN+HvIeD1hKzy7zvr2NZDKJJ48NitqEmf9Q4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uiCSn3uK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B64B6C433F1; Thu, 7 Mar 2024 17:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709833536; bh=fmex7ycV6097BZ7cnW/vpknMTfZttQAd8IWkJXjDdCU=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=uiCSn3uK2PCOZObe2iBQiz8z8ovbR3APKhEbgSFMsKF+lqN9MRj/o281oUEJsWaAc tp2ZiipVpH8YuCFs8ZoJ7D9ajIbkOA8Qd5awOXmmEcmhDlULZnDfyj4jSD7fybuyST 2l/+GTSHtx3wCFmJTIv0Bb8/K58F1oCm8ZLx3Ye2vPL/57axVKdR186mG6Sj+zoZo9 hW4lfEgFZdSUsJ30JRV51IR+akc/5QoyUaKfF0fmTbYRpSDuiUFvBv1J284+3ZDRNK TbmnASiMNsRXGSkA+caxy9I/iYXAPOleFcyCkFSoZoj/j3d40oZClTge5S7QwjRhYQ Ff8X0vdcoKZsA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 44C51CE0F1D; Thu, 7 Mar 2024 09:45:36 -0800 (PST) Date: Thu, 7 Mar 2024 09:45:36 -0800 From: "Paul E. McKenney" To: Stefan Wiehler Cc: Russell King , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , linux-arm-kernel@lists.infradead.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat Message-ID: <49792f54-fa11-4984-8611-84ba640a2b86@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20240307160951.3607374-1-stefan.wiehler@nokia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240307160951.3607374-1-stefan.wiehler@nokia.com> On Thu, Mar 07, 2024 at 05:09:51PM +0100, Stefan Wiehler wrote: > With CONFIG_PROVE_RCU_LIST=y and by executing > > $ echo 0 > /sys/devices/system/cpu/cpu1/online > > one can trigger the following Lockdep-RCU splat on ARM: > > ============================= > WARNING: suspicious RCU usage > 6.8.0-rc7-00001-g0db1d0ed8958 #10 Not tainted > ----------------------------- > kernel/locking/lockdep.c:3762 RCU-list traversed in non-reader section!! > > other info that might help us debug this: > > RCU used illegally from offline CPU! > rcu_scheduler_active = 2, debug_locks = 1 > no locks held by swapper/1/0. > > stack backtrace: > CPU: 1 PID: 0 Comm: swapper/1 Not tainted 6.8.0-rc7-00001-g0db1d0ed8958 #10 > Hardware name: Allwinner sun8i Family > unwind_backtrace from show_stack+0x10/0x14 > show_stack from dump_stack_lvl+0x60/0x90 > dump_stack_lvl from lockdep_rcu_suspicious+0x150/0x1a0 > lockdep_rcu_suspicious from __lock_acquire+0x11fc/0x29f8 > __lock_acquire from lock_acquire+0x10c/0x348 > lock_acquire from _raw_spin_lock_irqsave+0x50/0x6c > _raw_spin_lock_irqsave from check_and_switch_context+0x7c/0x4a8 > check_and_switch_context from arch_cpu_idle_dead+0x10/0x7c > arch_cpu_idle_dead from do_idle+0xbc/0x138 > do_idle from cpu_startup_entry+0x28/0x2c > cpu_startup_entry from secondary_start_kernel+0x11c/0x124 > secondary_start_kernel from 0x401018a0 > > The CPU is already reported as offline from RCU perspective in > cpuhp_report_idle_dead() before arch_cpu_idle_dead() is invoked. Above > RCU-Lockdep splat is then triggered by check_and_switch_context() acquiring the > ASID spinlock. > > Avoid the false-positive Lockdep-RCU splat by briefly reporting the CPU as > online again while the spinlock is held. > > Signed-off-by: Stefan Wiehler From an RCU perspective, this looks plausible. One question below. Thanx, Paul > --- > arch/arm/kernel/smp.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c > index 3431c0553f45..6875e2c5dd50 100644 > --- a/arch/arm/kernel/smp.c > +++ b/arch/arm/kernel/smp.c > @@ -319,7 +319,14 @@ void __noreturn arch_cpu_idle_dead(void) > { > unsigned int cpu = smp_processor_id(); > > + /* > + * Briefly report CPU as online again to avoid false positive > + * Lockdep-RCU splat when check_and_switch_context() acquires ASID > + * spinlock. > + */ > + rcutree_report_cpu_starting(cpu); > idle_task_exit(); > + rcutree_report_cpu_dead(); > > local_irq_disable(); Both rcutree_report_cpu_starting() and rcutree_report_cpu_dead() complain bitterly via lockdep if interrupts are enabled. And the call sites have interrupts disabled. So I don't understand what this local_irq_disable() is needed for.