Skip to contentSkip to conversation

genirq/matrix: Update availability for offline managed IRQ changes

PATCH Applied Avi Weiss 2 participants 2 messages Oct 25 – Nov 9

Subsystems (2)
lore
Share & tools
lore

Avi Weiss

author
#0 lore raw

PATCH 1/1 genirq/matrix: Update availability for offline managed IRQ changes

The IRQ matrix caches available vectors after a CPU's first online transition. Managed IRQ reservations can be added or removed while the CPU is offline, but irq_matrix_reserve_managed() and irq_matrix_remove_managed() only update cm->available for online CPUs.

When the CPU comes back online, irq_matrix_online() adds the stale count to m->global_available, causing vector availability to be overestimated (or potentially underestimated).

Update cm->available whenever the CPU matrix has been initialized, regardless of its online state. Continue updating global availability only for online CPUs, leaving first-time initialization to account for existing reservations.

Fixes 651ca2c00405 ("genirq/matrix: Handle CPU offlining proper")
---
 kernel/irq/matrix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/irq/matrix.c +4 -4
index faafb43a4e611..5a6adf8844903 100644
@@ -225,10 +225,10 @@ int irq_matrix_reserve_managed(struct irq_matrix *m, const struct cpumask *msk)
 		if (bit >= m->alloc_end)
 			goto cleanup;
 		cm->managed++;
-		if (cm->online) {
+		if (cm->initialized)
 			cm->available--;
+		if (cm->online)
 			m->global_available--;
-		}
 		trace_irq_matrix_reserve_managed(bit, cpu, m, cm);
 	}
 	return 0;
@@ -275,10 +275,10 @@ void irq_matrix_remove_managed(struct irq_matrix *m, const struct cpumask *msk)
 		clear_bit(bit, cm->managed_map);
 
 		cm->managed--;
-		if (cm->online) {
+		if (cm->initialized)
 			cm->available++;
+		if (cm->online)
 			m->global_available++;
-		}
 		trace_irq_matrix_remove_managed(bit, cpu, m, cm);
 	}
 }

base-commit: 21a7f44fd0765fcc5194130b28767786eba1d1e7

Signature · 1 line
2.43.0
merge bot Applied
#1 lore raw
The following commit has been merged into the irq/core branch of tip:

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     c3f7de51aac3f5b7a369222acb06509922268feb
Gitweb:        https://git.kernel.org/tip/c3f7de51aac3f5b7a369222acb06509922268feb
Author:        Avi Weiss <[email protected]>
AuthorDate:    Sun, 25 Oct 2026 18:40:46 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Mon, 09 Nov 2026 14:59:39 +01:00

genirq/matrix: Update availability for offline managed IRQ changes

The IRQ matrix caches available vectors after a CPU's first online transition. Managed IRQ reservations can be added or removed while the CPU is offline, but irq_matrix_reserve_managed() and irq_matrix_remove_managed() only update cm->available for online CPUs.

When the CPU comes back online, irq_matrix_online() adds the stale count to m->global_available, causing vector availability to be overestimated (or potentially underestimated).

Update cm->available whenever the CPU matrix has been initialized, regardless of its online state. Continue updating global availability only for online CPUs, leaving first-time initialization to account for existing reservations.

Fixes 651ca2c00405 ("genirq/matrix: Handle CPU offlining proper")
---
 kernel/irq/matrix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/irq/matrix.c +4 -4
index faafb43..5a6adf8 100644
@@ -225,10 +225,10 @@ int irq_matrix_reserve_managed(struct irq_matrix *m, const struct cpumask *msk)
 		if (bit >= m->alloc_end)
 			goto cleanup;
 		cm->managed++;
-		if (cm->online) {
+		if (cm->initialized)
 			cm->available--;
+		if (cm->online)
 			m->global_available--;
-		}
 		trace_irq_matrix_reserve_managed(bit, cpu, m, cm);
 	}
 	return 0;
@@ -275,10 +275,10 @@ void irq_matrix_remove_managed(struct irq_matrix *m, const struct cpumask *msk)
 		clear_bit(bit, cm->managed_map);
 
 		cm->managed--;
-		if (cm->online) {
+		if (cm->initialized)
 			cm->available++;
+		if (cm->online)
 			m->global_available++;
-		}
 		trace_irq_matrix_remove_managed(bit, cpu, m, cm);
 	}
 }