mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Clark Williams <clrkwllms@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev,
	Waiman Long <longman@redhat.com>
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	[thread overview]
Message-ID: <20260608022222.723265-3-longman@redhat.com> (raw)
In-Reply-To: <20260608022222.723265-1-longman@redhat.com>

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 <bigeasy@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Waiman Long <longman@redhat.com>
---
 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;
 
 	/*
-	 * 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;
 
 	/*
-	 * 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();
 }
 
 static void debug_objects_fill_pool(void)
-- 
2.54.0


  parent reply	other threads:[~2026-06-08  2:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08  2:22 [PATCH v6 0/2] " Waiman Long
2026-06-08  2:22 ` [PATCH v6 1/2] debugobjects: Add a can_fill_pool() helper for debug_objects_fill_pool() Waiman Long
2026-06-08  2:22 ` Waiman Long [this message]
2026-06-08  7:56 ` [PATCH v6 0/2] debugobjects: Don't call fill_pool() in early boot hardirq context Sebastian Andrzej Siewior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260608022222.723265-3-longman@redhat.com \
    --to=longman@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome