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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84DB9C54798 for ; Thu, 7 Mar 2024 18:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rpmt2hSQ1hTbRtpInM4W6MzaMKqGmVDyjzV4A9yEjIo=; b=efsurA40MC/wRb Dv3OHwhDV/+GXhCza84IYYS1LrVy7FfoukNjed8rNJcbBW6lMOO9t67KWxHKRRUGBuTubLH1oAs/c qfq+Br1s/GlobvAADE+hlanfUchNnLAFEK521MkfAVpktt6ZLbz018WTZ73VgVs5ea09tOoWgK9la mLmTy7e6ldCDbGU5bpLxMDAUVi1WD8Zq0fu5NG09nncJwS+Vb61e4IIXyM2Fxx6N7W5OF+AGwxV1K f0dxkBaQC/8sPO7xScYwagAJEtiXDzkYk8B9BMFXh9vhu6OH1ThZRHsv9/rwtRVkT005ccpuAWG4a xhork1utr+gQsAW3TCkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1riIpS-00000005vg9-1BBr; Thu, 07 Mar 2024 18:50:54 +0000 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1riIpP-00000005vfS-137k for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2024 18:50:52 +0000 Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-78822e21a9dso6306785a.2 for ; Thu, 07 Mar 2024 10:50:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709837450; x=1710442250; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=sf/Mj3BzGZKpoiOTKx5KymXugzcLyy+NNEJ46ZQm6pc=; b=b2W7fG7YNprsgggCOPALi/WJk41IZLJaicBQ4miI1iq1QpjeZ906ZyvEi9+LfSY0s9 0EYrTGUjM7mnUV1JEj+jKYAeaFEDTyPfhZP14DMzMveW2tWpdALnTCbYKyjjAtP7Y8cM GSQQ9aKaAZZTf4RjnX9wjLHFzHrxE1QPftyUGe/NLsjhXrUy7wqEEjh7foLoCuz7czZs V2iiN0T+Lub8SLcoVr3nifJH/8kzxOy6UNhyaV0LKDv58VulM0Mh6ijaTGMJ5c2J4vaK yuF7QBP+Qz2ZCV5Q4hieVBEsucHthoMWput/lFk5qxFNV0vQ3ZjC1UeOnjHwBk8QIQu0 QaWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709837450; x=1710442250; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:feedback-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sf/Mj3BzGZKpoiOTKx5KymXugzcLyy+NNEJ46ZQm6pc=; b=onAwmOjbWhQwwMayoyJ4NVb9EaGnSioqE/HfxfhHtqRBWAZYj4wp9U3ZhzkqOb7JV6 uSFLv0cWnNoBaETTD9eFeABVPd4C80KLiKh2jjvl6JNyBXZKbugr6iYV7oYRbhyxgmoI WJsPSc3SDbgXgswlGROeOkHoceeBzreF8wz/c7sM5CqUTbyv1m6fsj9MJlbHAug3/v8u Lj06VQv9iLlxAYiIi2icm9T619D9dWv5ztN0am3FrYk4TJRRWpVNE83NeHePrA694xek 53gjdipAf38lN1KL8RAfEpLbfR+05oFnxDeaRbjZFU5hZzWMfIDjfg0JBTsL9PB6x5S5 9NkA== X-Forwarded-Encrypted: i=1; AJvYcCXfUMX02sWQksJTgm9YJaxpYRd1QvMa+EYTBAO2txYMm6OfhgAKo+9hiotedn/TyyZZ8roaKdHAHACmoP5drmhb9ijSu+ipg7eWCRBrKu5OZIgrNaQ= X-Gm-Message-State: AOJu0YwntnTmTmmb5R9OL32q2gzc2jHNoODELdBN8UR5tISMnMhAyZzi RETu8/+9FDzxwWEIx+7i1X2k0czVCE7chdzyQ0g28nrKM+vmLP/ULmUixqZT X-Google-Smtp-Source: AGHT+IHJBaBGvoYxoVdhzF2YkImFqTt7kAT0cThOn47PelqcKokrA2FtS4u2q5ojr96oJ6JLK5cX1g== X-Received: by 2002:a05:620a:918:b0:788:1c6e:35c with SMTP id v24-20020a05620a091800b007881c6e035cmr8545244qkv.72.1709837449887; Thu, 07 Mar 2024 10:50:49 -0800 (PST) Received: from fauth2-smtp.messagingengine.com (fauth2-smtp.messagingengine.com. [103.168.172.201]) by smtp.gmail.com with ESMTPSA id 19-20020a05620a04d300b0078838c7acbfsm2810654qks.42.2024.03.07.10.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 10:50:49 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfauth.nyi.internal (Postfix) with ESMTP id 9FB3B1200043; Thu, 7 Mar 2024 13:50:48 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 07 Mar 2024 13:50:48 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrieefgdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhu nhcuhfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrg htthgvrhhnpeehudfgudffffetuedtvdehueevledvhfelleeivedtgeeuhfegueeviedu ffeivdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gsohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdei gedqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfih igmhgvrdhnrghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 7 Mar 2024 13:50:47 -0500 (EST) Date: Thu, 7 Mar 2024 10:49:41 -0800 From: Boqun Feng To: Stefan Wiehler Cc: Russell King , "Paul E. McKenney" , Joel Fernandes , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , linux-arm-kernel@lists.infradead.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Frederic Weisbecker Subject: Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat Message-ID: References: <20240307160951.3607374-1-stefan.wiehler@nokia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240307160951.3607374-1-stefan.wiehler@nokia.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240307_105051_315815_69258AE8 X-CRM114-Status: GOOD ( 24.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org [Cc Frederic] 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 I'm not sure this is a false-positive: if you traverse an RCU-list without RCU watching the CPU, then a grace period may pass, the next list can be garbage and you can go anywhere from the list. Or am I missing something that a CPU hotplug can block a grace period? But codewise, it looks good to me. Although I hope we can avoid calling rcutree_report_cpu_{starting,dead}() here and use something simple, however after a few attempts, I don't find a better way. Regards, Boqun > online again while the spinlock is held. > > Signed-off-by: Stefan Wiehler > --- > 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(); > > -- > 2.42.0 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel