Skip to content

Commit 217d453

Browse files
Yang Yingliangctmarinas
authored andcommitted
arm64: fix a migrating irq bug when hotplug cpu
When cpu is disabled, all irqs will be migratged to another cpu. In some cases, a new affinity is different, the old affinity need to be updated and if irq_set_affinity's return value is IRQ_SET_MASK_OK_DONE, the old affinity can not be updated. Fix it by using irq_do_set_affinity. And migrating interrupts is a core code matter, so use the generic function irq_migrate_all_off_this_cpu() to migrate interrupts in kernel/irq/migration.c. Cc: Jiang Liu <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Will Deacon <[email protected]> Cc: Russell King - ARM Linux <[email protected]> Cc: Hanjun Guo <[email protected]> Acked-by: Marc Zyngier <[email protected]> Signed-off-by: Yang Yingliang <[email protected]> Signed-off-by: Catalin Marinas <[email protected]>
1 parent a78afcc commit 217d453

File tree

4 files changed

+3
-64
lines changed

4 files changed

+3
-64
lines changed

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ config NR_CPUS
427427

428428
config HOTPLUG_CPU
429429
bool "Support for hot-pluggable CPUs"
430+
select GENERIC_IRQ_MIGRATION
430431
help
431432
Say Y here to experiment with turning CPUs off and on. CPUs
432433
can be controlled through /sys/devices/system/cpu.

arch/arm64/include/asm/irq.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
struct pt_regs;
99

10-
extern void migrate_irqs(void);
1110
extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
1211

1312
static inline void acpi_irq_init(void)

arch/arm64/kernel/irq.c

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <linux/init.h>
2828
#include <linux/irqchip.h>
2929
#include <linux/seq_file.h>
30-
#include <linux/ratelimit.h>
3130

3231
unsigned long irq_err_count;
3332

@@ -54,64 +53,3 @@ void __init init_IRQ(void)
5453
if (!handle_arch_irq)
5554
panic("No interrupt controller found.");
5655
}
57-
58-
#ifdef CONFIG_HOTPLUG_CPU
59-
static bool migrate_one_irq(struct irq_desc *desc)
60-
{
61-
struct irq_data *d = irq_desc_get_irq_data(desc);
62-
const struct cpumask *affinity = irq_data_get_affinity_mask(d);
63-
struct irq_chip *c;
64-
bool ret = false;
65-
66-
/*
67-
* If this is a per-CPU interrupt, or the affinity does not
68-
* include this CPU, then we have nothing to do.
69-
*/
70-
if (irqd_is_per_cpu(d) || !cpumask_test_cpu(smp_processor_id(), affinity))
71-
return false;
72-
73-
if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
74-
affinity = cpu_online_mask;
75-
ret = true;
76-
}
77-
78-
c = irq_data_get_irq_chip(d);
79-
if (!c->irq_set_affinity)
80-
pr_debug("IRQ%u: unable to set affinity\n", d->irq);
81-
else if (c->irq_set_affinity(d, affinity, false) == IRQ_SET_MASK_OK && ret)
82-
cpumask_copy(irq_data_get_affinity_mask(d), affinity);
83-
84-
return ret;
85-
}
86-
87-
/*
88-
* The current CPU has been marked offline. Migrate IRQs off this CPU.
89-
* If the affinity settings do not allow other CPUs, force them onto any
90-
* available CPU.
91-
*
92-
* Note: we must iterate over all IRQs, whether they have an attached
93-
* action structure or not, as we need to get chained interrupts too.
94-
*/
95-
void migrate_irqs(void)
96-
{
97-
unsigned int i;
98-
struct irq_desc *desc;
99-
unsigned long flags;
100-
101-
local_irq_save(flags);
102-
103-
for_each_irq_desc(i, desc) {
104-
bool affinity_broken;
105-
106-
raw_spin_lock(&desc->lock);
107-
affinity_broken = migrate_one_irq(desc);
108-
raw_spin_unlock(&desc->lock);
109-
110-
if (affinity_broken)
111-
pr_warn_ratelimited("IRQ%u no longer affine to CPU%u\n",
112-
i, smp_processor_id());
113-
}
114-
115-
local_irq_restore(flags);
116-
}
117-
#endif /* CONFIG_HOTPLUG_CPU */

arch/arm64/kernel/smp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ int __cpu_disable(void)
231231
/*
232232
* OK - migrate IRQs away from this CPU
233233
*/
234-
migrate_irqs();
234+
irq_migrate_all_off_this_cpu();
235+
235236
return 0;
236237
}
237238

0 commit comments

Comments
 (0)