[PATCH v6 2/2] debugobjects: Don't call fill_pool() in early boot hardirq context
From: Waiman Long
Date: Sun Jun 07 2026 - 22:24:12 EST
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@xxxxxxxxxxxxx>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Signed-off-by: Waiman Long <longman@xxxxxxxxxx>
---
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