[PATCH 04/15] genirq: Support dynamic migration for managed interrupts

Qiliang Yuan
2026-03-25T09:10:16Z

Managed interrupts currently have their affinity determined once,
honoring boot-time isolation settings. There is no mechanism to migrate
them when housekeeping boundaries change at runtime.

Enable managed interrupts to respond dynamically to housekeeping updates.

This ensures that managed interrupts are migrated away from newly
isolated CPUs or redistributed when housekeeping CPUs are added.

Signed-off-by: Qiliang Yuan <realwujing@gmail.com>
---
kernel/irq/manage.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 349ae7979da0e..f2cba3d7ef624 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -2811,3 +2811,52 @@ bool irq_check_status_bit(unsigned int irq, unsigned int bitmask)
return res;
}
EXPORT_SYMBOL_GPL(irq_check_status_bit);
+
+#ifdef CONFIG_SMP
+static int irq_housekeeping_reconfigure(struct notifier_block *nb,
+ unsigned long action, void *data)
+{
+ struct housekeeping_update *upd = data;
+ unsigned int irq;
+
+ if (action != HK_UPDATE_MASK || upd->type != HK_TYPE_MANAGED_IRQ)
+ return NOTIFY_OK;
+
+ irq_lock_sparse();
+ for_each_active_irq(irq) {
+ struct irq_data *irqd;
+ struct irq_desc *desc;
+
+ desc = irq_to_desc(irq);
+ if (!desc)
+ continue;
+
+ scoped_guard(raw_spinlock_irqsave, &desc->lock) {
+ irqd = irq_desc_get_irq_data(desc);
+ if (!irqd_affinity_is_managed(irqd) || !desc->action ||
+ !irq_data_get_irq_chip(irqd))
+ continue;
+
+ /*
+ * Re-apply existing affinity to honor the new
+ * housekeeping mask via __irq_set_affinity() logic.
+ */
+ irq_set_affinity_locked(irqd, irq_data_get_affinity_mask(irqd), false);
+ }
+ }
+ irq_unlock_sparse();
+
+ return NOTIFY_OK;
+}
+
+static struct notifier_block irq_housekeeping_nb = {
+ .notifier_call = irq_housekeeping_reconfigure,
+};
+
+static int __init irq_init_housekeeping_notifier(void)
+{
+ housekeeping_register_notifier(&irq_housekeeping_nb);
+ return 0;
+}
+core_initcall(irq_init_housekeeping_notifier);
+#endif

--
2.43.0