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 8F78BC5475B for ; Fri, 8 Mar 2024 14:58:05 +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:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wrorLLGpXAjjv+53IoDMIV6Fm/ambBdPsfwAO6f8lZQ=; b=bafM7vNRYicIGy ZJITJvIa5aSbKcPHbxHsItH5e7MOQP9VJ7eVstAy2AzMAVGMwM2BOxKrc9yXebOujC3/8rTE0w86+ F+Nu1gIveXcyv0vuhzP3ItZoFgd10mB+T2q2x9ywh6FC7rsHl9qRpWE/vyQrcuVCEY8HSibfMv/gT XtJZsLMIhfc3NxdcB4uR3KEOtfwFV8rekNaRGzGsP+7uz8ijjjWoJvyQdlDfY3dIpPdPU8xZzw1XG 36pBV9oc41775gnXj33UBzOBhybm6IDMmVGRhc660Yl+59l47PgcUW+oR8vubmrw2cioxcB5nV91L xUtrQfyemFK9tPI+zb/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ribfT-00000009i3S-1CYk; Fri, 08 Mar 2024 14:57:51 +0000 Received: from mail-qv1-xf2c.google.com ([2607:f8b0:4864:20::f2c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ribfP-00000009i0q-23Jy for linux-arm-kernel@lists.infradead.org; Fri, 08 Mar 2024 14:57:48 +0000 Received: by mail-qv1-xf2c.google.com with SMTP id 6a1803df08f44-690bba32309so897466d6.0 for ; Fri, 08 Mar 2024 06:57:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1709909866; x=1710514666; darn=lists.infradead.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=zHs25ksJpqEeOp1pNTzGqltTuGv83hVjOZuwqlpctzQ=; b=VffomQDwlZRAIlSRBQ2b6Q1e27oN966CQsJRPGlecB4TkHRxAaeMA9lXSXSSnrjvRo HUhiGwwamc70ZvSLB7P8U+S0nbGrSS7shY6ykjqV5m0UFwm+ub2rhp998/qk7OOd1z6r trESIHPt7ARB3qma0c2l+vdWBVgsRJzbyAqZ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709909866; x=1710514666; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zHs25ksJpqEeOp1pNTzGqltTuGv83hVjOZuwqlpctzQ=; b=CjjuNNcKf5bc6KIDlE1rfaePMoR1FKcj6PEelU2rsNowhQSu0zpaj/pL6PbQ2ZvKN0 vt7sp+tuVgv90B+/BUZryzFJ33FhAWdomz2w5tZzfXTsxfrrXaFbFu8LM4Im3HVunSl8 i8F7QVksryZtA4Km/Tgh43SrvjGZKF7RuI/WaXNBFIJYVFl8+QBdAzkVvea+6bFocrrT 1QjHXkvKm/wRYPFI/WerTtWpHeTwPHYTdyAp7gu/APUT9L0+91pATRtO+O+bUTwzkFSu YbLQGEJzAqQcRlGgImBS0+Oj8Si3+0Z4zM9/qQQxvUe22tQDSlgOmVflmATbrVandcPl Ws9A== X-Forwarded-Encrypted: i=1; AJvYcCWQLtoMsAIcW4lPTRZyRhc7Y0nQmquQBiZUGx9S5WIeulhVZ4DTyNOnRjtSPIOywnwcDlMw7N18DdNlCOPfGTsr6rW7/cqnyCu+pr/PkmkCppbUwHc= X-Gm-Message-State: AOJu0Yy2HrSzy2HQWSu7PPGq5FWGMlMf5wXFynx7WXalgH0yKc/8J7VC 1jwqViBA5F1kwWnYwQb8VwLIdfW5OWUmiCG2bOoD1YfyR/RlcV9lkHrHy78l7o4= X-Google-Smtp-Source: AGHT+IFgMYXjfmNrjnOEWaK0ByL3HTUskDb8AyXDaoxRYm0ZxLkEmiG2mFQnS6LbDZxo9RDmgpMRMQ== X-Received: by 2002:a05:6214:a63:b0:690:7dc5:a9bc with SMTP id ef3-20020a0562140a6300b006907dc5a9bcmr12454963qvb.29.1709909865438; Fri, 08 Mar 2024 06:57:45 -0800 (PST) Received: from [10.5.0.2] ([91.196.69.182]) by smtp.gmail.com with ESMTPSA id ld8-20020a056214418800b0068fef1264f6sm9765794qvb.101.2024.03.08.06.57.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Mar 2024 06:57:44 -0800 (PST) Message-ID: Date: Fri, 8 Mar 2024 09:57:42 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] arm: smp: Avoid false positive CPU hotplug Lockdep-RCU splat To: Stefan Wiehler , Russell King , "Paul E. McKenney" , Josh Triplett , Boqun Feng Cc: Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , linux-arm-kernel@lists.infradead.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240307160951.3607374-1-stefan.wiehler@nokia.com> Content-Language: en-US From: Joel Fernandes 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-20240308_065747_568472_8AFAB18E X-CRM114-Status: GOOD ( 21.52 ) 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 On 3/7/2024 11:09 AM, 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 > --- > 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(); I agree with the problem but disagree with the patch because it feels like a terrible workaround. Can we just use arch_spin_lock() for the cpu_asid_lock? This might require acquiring the raw_lock within the raw_spinlock_t, but there is precedent: arch/powerpc/kvm/book3s_hv_rm_mmu.c:245: arch_spin_lock(&kvm->mmu_lock.rlock.raw_lock); IMO, lockdep tracking of this lock is not necessary or possible considering the hotplug situation. Or is there a reason you need lockdep working for the cpu_asid_lock? thanks, - Joel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel