From nobody Mon Jun 8 05:25:26 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 4B3C230F547 for ; Mon, 8 Jun 2026 02:23:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780885407; cv=none; b=U+zTy4UbxL+ELdMHDDAld+jFYa+gH4a+ORAd+7GhX1fuxH9tkkvAHCo92fxiDtnlLFFDiEl03wGqHBdkcI83sOXcylnbjqrlyIJbBpeLa+kaGfyTJ7aTOZYZQ3F/Ru54kaUA0gwTM/8rbb3iD5/+a2mEBqRAPRXs3Bg1ZryW1u0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780885407; c=relaxed/simple; bh=1dqjeTXq2/01kDuF3HpXMO1cfM745PC+ileuKbWH/dg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PVSBgwPlcDuYAR38PQA0m5LywyqWw5AVKWFtnsxhCibj58Gdgd8exGd5WgjD5kDv9oLi1XNifuwDzOLxmg1iJzTrPnDbGVSs1NTCpyrd2FRE72RfBtrpUoNF5ZdLu94Q6ZISBXx9reAgFsfUVYE/mzv8rDLTT0cij602yQ7pK+s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Knftys9F; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Knftys9F" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780885405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ILywUoltnn1EtjSpguSVVCO1VF4yG/cINhF/dYcn1P0=; b=Knftys9FDbwOVEtYwcp5fnSQE0npHmgtKdyodocBVCNBD0onWhfUdjmgaSCN/ukrUSZpP2 nsH4GYoJruKnW4QWX0J6kdE3LWgsLUHxh4KFFdPtbT+EL16S8s4bfmfjvUoYNwDNypKYlG BVy5JeCTxH4JMhE/4o6j3W5EVZDVUtA= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-465-c4hoiibGPAi3sXizzZVLYQ-1; Sun, 07 Jun 2026 22:23:22 -0400 X-MC-Unique: c4hoiibGPAi3sXizzZVLYQ-1 X-Mimecast-MFC-AGG-ID: c4hoiibGPAi3sXizzZVLYQ_1780885400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9D4871800347; Mon, 8 Jun 2026 02:23:20 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.22.88.52]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 29AD319560A3; Mon, 8 Jun 2026 02:23:19 +0000 (UTC) From: Waiman Long To: Thomas Gleixner , Ingo Molnar , Andrew Morton , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, Waiman Long Subject: [PATCH v6 1/2] debugobjects: Add a can_fill_pool() helper for debug_objects_fill_pool() Date: Sun, 7 Jun 2026 22:22:21 -0400 Message-ID: <20260608022222.723265-2-longman@redhat.com> In-Reply-To: <20260608022222.723265-1-longman@redhat.com> References: <20260608022222.723265-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" The conditional check in debug_objects_fill_pool() for determining if fill_pool() can be called is now quite complicated. Add a new can_fill_pool() helper to break down the conditions individually to make them easier to understand. No functional change is expected. Suggested-by: Thomas Gleixner Signed-off-by: Waiman Long --- lib/debugobjects.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index b18a682fe3da..1d826689611f 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -720,6 +720,30 @@ static inline bool debug_objects_is_pi_blocked_on(void) #endif } =20 +static inline bool can_fill_pool(void) +{ + /* + * On !RT enabled kernels there are no restrictions and spinlock_t and + * raw_spinlock_t are the same types. + */ + if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + return true; + + /* + * On RT enabled kernels the pool refill must happen in preemptible + * context and the task must not be blocked on a lock as that could + * corrupt the PI state when blocking on a lock in the allocation path. + */ + if (preemptible() && !debug_objects_is_pi_blocked_on()) + return true; + + /* + * Allow refilling to happen early in the boot with disabled interrupts + * as long as the scheduler is not operational. + */ + return system_state < SYSTEM_SCHEDULING; +} + static void debug_objects_fill_pool(void) { if (!static_branch_likely(&obj_cache_enabled)) @@ -734,18 +758,11 @@ static void debug_objects_fill_pool(void) if (likely(!pool_should_refill(&pool_global))) return; =20 - /* - * On RT enabled kernels the pool refill must happen in preemptible - * context and not enqueued on an rt_mutex -- for !RT kernels we rely - * on the fact that spinlock_t and raw_spinlock_t are basically the - * same type and this lock-type inversion works just fine. - */ - if (!IS_ENABLED(CONFIG_PREEMPT_RT) || system_state < SYSTEM_SCHEDULING || - (preemptible() && !debug_objects_is_pi_blocked_on())) { + if (can_fill_pool()) { /* * Annotate away the spinlock_t inside raw_spinlock_t warning * by temporarily raising the wait-type to LD_WAIT_CONFIG, matching - * the preemptible() condition above. + * the preemptible() condition in can_fill_pool(). */ static DEFINE_WAIT_OVERRIDE_MAP(fill_pool_map, LD_WAIT_CONFIG); lock_map_acquire_try(&fill_pool_map); --=20 2.54.0 From nobody Mon Jun 8 05:25:26 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 79D6B317158 for ; Mon, 8 Jun 2026 02:23:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780885409; cv=none; b=IdLeiF/cXQ1kTdUySWKOkpE6r9bBuiG6RvmIn5wMc05CwGUDhEcGL7AFU+p1MkpJ+cakzqCQeoTLXXCqezJd+GP9TXIXZmBNwuxjLd2AuQo9yZ3KMeOy11zHEXZ1G/8YtUBVeCFM31BRq1cC2ArPINVdyNOi4YNkAUmDhFjD3FU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780885409; c=relaxed/simple; bh=5uEFQX5H+pvZr1FacZzRG6H2gRVcWvvvASwYlGJkkl4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ym0J+h8Q7rUn2Q5w2/gmWlM7WVxhJmDoTEdoSzh5f5N8DZZK3VLdRXXzGDnZx1e0OtyNJz73v93TIEqxa48Kmf48GhwXJNd4Z5ssmSCdN67sD7nANWuYF4fmaVFlI+njDWkKvN3Ra2fmsZOGh0zeRGjyc4UajVgFMwo2ry1HsQ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Dk+NCVuB; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Dk+NCVuB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780885407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O4pjEPP6UIRdrTl3K9yWNXm50pFPMXWUEr7RuLd2pZY=; b=Dk+NCVuBW5zyl72L4ff8Exkwc7oYG9EPhE0ZtNS91jo4+bh1UUkWrWM9j/M6Uy+siM03+w ihGCwKRlz5aCNPrVopztKjdQXFzz24mbZAdbaX/HkBj5/vr/FiWHer9tUtsYK9sX7bVth8 WwpzV5c19zd+k5D0I6UbFaN2p2mtXiw= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-19-7ihvBpDDPgatnrQ6QHPnvw-1; Sun, 07 Jun 2026 22:23:24 -0400 X-MC-Unique: 7ihvBpDDPgatnrQ6QHPnvw-1 X-Mimecast-MFC-AGG-ID: 7ihvBpDDPgatnrQ6QHPnvw_1780885402 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 570AB180047F; Mon, 8 Jun 2026 02:23:22 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.22.88.52]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D083519560A2; Mon, 8 Jun 2026 02:23:20 +0000 (UTC) From: Waiman Long To: Thomas Gleixner , Ingo Molnar , Andrew Morton , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, Waiman Long Subject: [PATCH v6 2/2] debugobjects: Don't call fill_pool() in early boot hardirq context Date: Sun, 7 Jun 2026 22:22:22 -0400 Message-ID: <20260608022222.723265-3-longman@redhat.com> In-Reply-To: <20260608022222.723265-1-longman@redhat.com> References: <20260608022222.723265-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" When booting a debug PREEMPT_RT kernel on an arm64 system with grace processor, a "inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage" lockdep warning message was reported to the console. During early boot, interrupts are getting enabled before the scheduler is enabled. In this window (before SYSTEM_SCHEDULING is set) interrupts can fire and attempt to fill the pool from within the hardirq. This can lead to a deadlock the interrupt occurred while in the memory allocator. Reorder the exception rules and forbid this scenario by excluding allocations from hardirq. Fixes: 06e0ae988f6e ("debugobjects: Allow to refill the pool before SYSTEM_= SCHEDULING") Suggested-by: Sebastian Andrzej Siewior Reviewed-by: Sebastian Andrzej Siewior Signed-off-by: Waiman Long --- lib/debugobjects.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 1d826689611f..6fb00e08a4e2 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -730,18 +730,29 @@ static inline bool can_fill_pool(void) return true; =20 /* - * On RT enabled kernels the pool refill must happen in preemptible - * context and the task must not be blocked on a lock as that could - * corrupt the PI state when blocking on a lock in the allocation path. + * On RT enabled kernels, the task must not be blocked on a lock as + * that could corrupt the PI state when blocking on a lock in the + * allocation path. */ - if (preemptible() && !debug_objects_is_pi_blocked_on()) + if (debug_objects_is_pi_blocked_on()) + return false; + + /* + * On RT enabled kernels the pool refill should happen in preemptible + * context. + */ + if (preemptible()) return true; =20 /* - * Allow refilling to happen early in the boot with disabled interrupts - * as long as the scheduler is not operational. + * Though during system boot before scheduling is set up, preemption is + * disabled and the pool can get exhausted. Before scheduling is active + * a task cannot be blocked on a sleeping lock, but it might hold a lock + * and if interrupted then hard interrupt context might run into a lock + * inversion. So exclude hard interrupt context from allocations before + * scheduling is active. */ - return system_state < SYSTEM_SCHEDULING; + return system_state < SYSTEM_SCHEDULING && !in_hardirq(); } =20 static void debug_objects_fill_pool(void) --=20 2.54.0