Commit 651ca2c0 authored by Thomas Gleixner's avatar Thomas Gleixner

genirq/matrix: Handle CPU offlining proper

At CPU hotunplug the corresponding per cpu matrix allocator is shut down and
the allocated interrupt bits are discarded under the assumption that all
allocated bits have been either migrated away or shut down through the
managed interrupts mechanism.

This is not true because interrupts which are not started up might have a
vector allocated on the outgoing CPU. When the interrupt is started up
later or completely shutdown and freed then the allocated vector is handed
back, triggering warnings or causing accounting issues which result in
suspend failures and other issues.

Change the CPU hotplug mechanism of the matrix allocator so that the
remaining allocations at unplug time are preserved and global accounting at
hotplug is correctly readjusted to take the dormant vectors into account.

Fixes: 2f75d9e1 ("genirq: Implement bitmap matrix allocator")
Reported-by: default avatarYuriy Vostrikov <delamonpansie@gmail.com>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Tested-by: default avatarYuriy Vostrikov <delamonpansie@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20180222112316.849980972@linutronix.de
parent 89426646
...@@ -16,6 +16,7 @@ struct cpumap { ...@@ -16,6 +16,7 @@ struct cpumap {
unsigned int available; unsigned int available;
unsigned int allocated; unsigned int allocated;
unsigned int managed; unsigned int managed;
bool initialized;
bool online; bool online;
unsigned long alloc_map[IRQ_MATRIX_SIZE]; unsigned long alloc_map[IRQ_MATRIX_SIZE];
unsigned long managed_map[IRQ_MATRIX_SIZE]; unsigned long managed_map[IRQ_MATRIX_SIZE];
...@@ -81,9 +82,11 @@ void irq_matrix_online(struct irq_matrix *m) ...@@ -81,9 +82,11 @@ void irq_matrix_online(struct irq_matrix *m)
BUG_ON(cm->online); BUG_ON(cm->online);
bitmap_zero(cm->alloc_map, m->matrix_bits); if (!cm->initialized) {
cm->available = m->alloc_size - (cm->managed + m->systembits_inalloc); cm->available = m->alloc_size;
cm->allocated = 0; cm->available -= cm->managed + m->systembits_inalloc;
cm->initialized = true;
}
m->global_available += cm->available; m->global_available += cm->available;
cm->online = true; cm->online = true;
m->online_maps++; m->online_maps++;
...@@ -370,14 +373,16 @@ void irq_matrix_free(struct irq_matrix *m, unsigned int cpu, ...@@ -370,14 +373,16 @@ void irq_matrix_free(struct irq_matrix *m, unsigned int cpu,
if (WARN_ON_ONCE(bit < m->alloc_start || bit >= m->alloc_end)) if (WARN_ON_ONCE(bit < m->alloc_start || bit >= m->alloc_end))
return; return;
if (cm->online) { clear_bit(bit, cm->alloc_map);
clear_bit(bit, cm->alloc_map); cm->allocated--;
cm->allocated--;
if (cm->online)
m->total_allocated--; m->total_allocated--;
if (!managed) {
cm->available++; if (!managed) {
cm->available++;
if (cm->online)
m->global_available++; m->global_available++;
}
} }
trace_irq_matrix_free(bit, cpu, m, cm); trace_irq_matrix_free(bit, cpu, m, cm);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment