From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 08383330D35 for ; Mon, 17 Nov 2025 13:55:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763387711; cv=none; b=gn6uhy7nfb06AfM7XDg+qcpI7W05yyvHDK0Epey+LKC+X0Em4VNyJk6VIIjmuHxg3AnS1KfRJEMqqyQwbMgq0EAt8JbhDsLlbkAudZ0Iugm9eUcTApV/DGBFd4bBtYJhrBvwlg6IvcNkqfK+zFjRUt0pyG9pc8DzdtpXjvIlazI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763387711; c=relaxed/simple; bh=/4YYlArvAvXZHUVejuk8TrCnvCIMriwqMIg5wYQTJTU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Btrfkgzye8jOQY2+VAnVYo4C92lFWQP+kCJKPm7JE+05RJ9WtEpwi3CFgBtAn7Rqr/tFqc+WFWl1qA7hdOikpBbI1kw8QRtDT7Q9hN+V3no729+Ch8cc+o/PMCc8TzdgPPitVTMWrrTu8CUzzEN2yA5CdpcHLTyvkUw3qop2uQo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ZMMV5NoA; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Jeqyxq10; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ZMMV5NoA"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Jeqyxq10" Date: Mon, 17 Nov 2025 14:55:05 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1763387707; 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=EG+TwUrosiy3Sb3L3o1l8rIjZXQJfN7Q9CmNJqVlOMc=; b=ZMMV5NoA8Cf9FAGRQ7BNE6TvmnYD1AakECuNi0g12o+ZzUTtvk61LLqvbu1rY+yxVdsehI brGcscDQWzhzyEK7YW6u87et2Hush2WVH2XLIxWxCsZSdHnk5MiZR0bz0z70S0pycTm555 OYIp31cnIJ12Qu3VMqJb47Oi2yUsaMM0vA2lhcQ1Z7Pp/EB4rFB6zHfKhOU2lvbOZoOUWW HHdDN5jD/4j/OIaQRWbCOcO6kcduEItV61LJkvgFFcYeJXqDwjkNRlL7G7zUL3ZHIt7P7u d8BWzqvUnp3+mQZ+0Jv7O67NghSxZ27gm8NeFcVqbi3BThGZyeuiIilfb6zEzQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1763387707; 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=EG+TwUrosiy3Sb3L3o1l8rIjZXQJfN7Q9CmNJqVlOMc=; b=Jeqyxq10LT1N8QYOcyMfnSM9rdAPyvdImdnezC0m/TdDbV5YxZ9l2/78SJLMcmGnPvPdt2 XyTeIpbF3dwZPiDQ== From: "bigeasy@linutronix.de" To: "Sverdlin, Alexander" Cc: "mingo@kernel.org" , "peterz@infradead.org" , "linux-kernel@vger.kernel.org" , "torvalds@linux-foundation.org" , "tglx@linutronix.de" , "paulmck@kernel.org" , "rostedt@goodmis.org" , "will@kernel.org" , "joel@joelfernandes.org" Subject: Re: [PATCH 6/9] lockdep: Introduce wait-type checks Message-ID: <20251117135505.K9WJefrH@linutronix.de> References: <20200313174701.148376-1-bigeasy@linutronix.de> <20200313174701.148376-7-bigeasy@linutronix.de> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: On 2025-11-17 13:42:40 [+0000], Sverdlin, Alexander wrote: > Hello Peter and all, >=20 > I'm trying to understand the splat I've got with v6.18-rc1: >=20 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > [ BUG: Invalid wait context ] > 6.18.0-rc1+git476309497a53 #1 Tainted: G O =20 > ----------------------------- > some-user-space-process/1251 is trying to lock: > ffff000005cbc548 (&counter->events_list_lock){....}-{3:3}, at: counter_pu= sh_event+0x68/0x430 [counter] > other info that might help us debug this: > context-{2:2} > no locks held by some-user-space-process/1251. > stack backtrace: > CPU: 0 UID: 0 PID: 1251 Comm: some-user-space-process Tainted: G = O 6.18.0-rc1+git476309497a53 #1 PREEMPT=20 > Call trace: > show_stack+0x20/0x38 (C) > dump_stack_lvl+0x8c/0xd0 > dump_stack+0x18/0x28 > __lock_acquire+0x91c/0x1f78 > lock_acquire+0x1c4/0x338 > _raw_spin_lock_irqsave+0x68/0x98 > counter_push_event+0x68/0x430 [counter] > interrupt_cnt_isr+0x40/0x78 [interrupt_cnt] > __handle_irq_event_percpu+0xa4/0x398 > handle_irq_event+0x54/0xb8 > handle_simple_irq+0xe4/0x128 > handle_irq_desc+0x48/0x68 > generic_handle_domain_irq+0x24/0x38 > gpio_irq_handler+0xa0/0x140 > handle_irq_desc+0x48/0x68 > generic_handle_domain_irq+0x24/0x38 > gic_handle_irq+0x54/0x128 > call_on_irq_stack+0x30/0x70 > do_interrupt_handler+0x88/0x98 > el0_interrupt+0x5c/0x270 > __el0_irq_handler_common+0x18/0x28 > el0t_64_irq_handler+0x10/0x20 > el0t_64_irq+0x198/0x1a0 >=20 > This is not PREEMPT_RT, but still CONFIG_PROVE_RAW_LOCK_NESTING=3Dy confi= g... > The relevant logic in the current v6.18-rcX is still largely unchanged > from the Subject commit and... >=20 The validation is not limited to PREEMPT_RT enabled. =E2=80=A6 > > diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c > > index 32406ef0d6a2d..4a9abf8bd9d15 100644 > > --- a/kernel/locking/lockdep.c > > +++ b/kernel/locking/lockdep.c =E2=80=A6 > > + * Set appropriate wait type for the context; for IRQs we have to take > > + * into account force_irqthread as that is implied by PREEMPT_RT. > > + */ > > + if (curr->hardirq_context) { > > + /* > > + * Check if force_irqthreads will run us threaded. > > + */ > > + if (curr->hardirq_threaded) > > + curr_inner =3D LD_WAIT_CONFIG; > > + else > > + curr_inner =3D LD_WAIT_SPIN; >=20 > ... even though it's "if (curr->hardirq_threaded || curr->irq_config)" in= the > meanwhile, it is unclear to me, why is it conditional at all and not alwa= ys > "LD_WAIT_CONFIG" in hardirq context? >=20 > With !PREEMPT_RT but CONFIG_PROVE_RAW_LOCK_NESTING=3Dy we always end up > with LD_WAIT_SPIN here and it always warns if we take "spinlock_t" in har= dirq > context (as in the splat above). But the latter should be legal under all > circumstances, isn't it? Nope. The validation is performed always. The architectures which don't support PREEMPT_RT are excluded for $reasons that is why PROVE_RAW_LOCK_NESTING remains an option there. A spinlock_t is a sleeping lock in a PREEMPT_RT context and the interrupt hander are threaded. In this case a spinlock_t is okay. However, if a spinlock_t is used in a non-forced-threaded environment (such as in a primary handler with IRQF_NO_THREAD) then this handler will not be threaded. Therefore spinlock_t is not a valid class. Sebastian