arm/arm64: fix a migrating irq bug when hotplug cpu
Subsystems (3)
v5 cover arm/arm64: fix a migrating irq bug when hotplug cpu
----
Changes in v5:
- remove the macro that guard move_irqs()
- use name irq_migrate_all_off_this_cpu instead of move_irqs
Changes in v4:
- select GENERIC_IRQ_MIGRATION when config GENERIC_IRQ_MIGRATION is enabled
- add move_irqs() into kerne/irq/migration.c for cpu hotplug
- use move_irqs() to migrate interrupts on arm/arm64 when cpu is going to down
- split bugfix patch into seperate patches for arm and arm64
Changes in v3:
- introduce config GENERIC_IRQ_MIGRATION for compiling migration.c
- rename migrate_irqs in arch/ia64/kernel/irq.c to avoid compiling error
Changes in v2:
- use the exiting helper to set IRQD_MOVE_PCNTXT flag
- use for_each_active_irq() instead of for_each_irq_desc()
- add some warn messages when affinity is null or do set affinity failed
----
Hi All,
There is a bug:
When cpu is disabled, all irqs will be migratged to another cpu. In some cases, a new affinity is different, it needed to be coppied to irq's affinity. But if the type of irq is LPI, it's affinity will not be coppied because of irq_set_affinity's return value.
As Marc and Will suggested, I refactor the arm/arm64 migrating interrupts code and fix the migrating irq bug while cpu is offline.
I'm trying let the core code do the migrating interrupts matter. kernel/irq/migration.c depends on CONFIG_GENERIC_PENDING_IRQ, so I introduce config GENERIC_IRQ_MIGRATION for compiling migration.c. Then add a generic function for migrating interrupts in migration.c. And then use the function when cpu is going to down on arm and arm64.
Yang Yingliang (4):
genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION
genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug
arm64: fix a migrating irq bug when hotplug cpu
arm: fix a migrating irq bug when hotplug cpu
arch/arm/Kconfig | 1 + arch/arm/include/asm/irq.h | 1 - arch/arm/kernel/irq.c | 62 ----------------------------------------- arch/arm/kernel/smp.c | 2 +- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/irq.h | 1 - arch/arm64/kernel/irq.c | 62 ----------------------------------------- arch/arm64/kernel/smp.c | 2 +- include/linux/irq.h | 2 ++ kernel/irq/Kconfig | 5 ++++ kernel/irq/Makefile | 2 +- kernel/irq/migration.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 78 insertions(+), 129 deletions(-)
Signature · 1 line
2.5.0
RFC PATCH v5 1/4 genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION
Introduce a more general config for compile kernel/irq/migration.c. Move the CONFIG_GENERIC_PENDING_IRQ into migration.c. So we can move other migration interrupts code into migration.c without select CONFIG_GENERIC_PENDING_IRQ.
--- kernel/irq/Kconfig | 5 +++++ kernel/irq/Makefile | 2 +- kernel/irq/migration.c | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-)
kernel/irq/Kconfig +5 -0
@@ -29,6 +29,11 @@ config GENERIC_IRQ_LEGACY_ALLOC_HWIRQ # Support for delayed migration from interrupt context config GENERIC_PENDING_IRQ bool + select GENERIC_IRQ_MIGRATION + +# Support for generic irq migration +config GENERIC_IRQ_MIGRATION + bool # Alpha specific irq affinity mechanism config AUTO_IRQ_AFFINITY
kernel/irq/Makefile +1 -1
@@ -4,6 +4,6 @@ obj-$(CONFIG_GENERIC_IRQ_CHIP) += generic-chip.o obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o obj-$(CONFIG_IRQ_DOMAIN) += irqdomain.o obj-$(CONFIG_PROC_FS) += proc.o -obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o +obj-$(CONFIG_GENERIC_IRQ_MIGRATION) += migration.o obj-$(CONFIG_PM_SLEEP) += pm.o obj-$(CONFIG_GENERIC_MSI_IRQ) += msi.o
kernel/irq/migration.c +2 -0
@@ -4,6 +4,7 @@#include "internals.h" +#ifdef CONFIG_GENERIC_PENDING_IRQ void irq_move_masked_irq (struct irq_data *idata) {struct irq_desc *desc =irq_data_to_desc (idata);
@@ -77,3 +78,4 @@ void irq_move_irq(struct irq_data *idata)if (!masked) idata->chip->irq_unmask(idata); } +#endif
Signature · 1 line
2.5.0
Re: [RFC PATCH v5 1/4] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION
Quoted 5 lines · On Sat, 19 Sep 2015 11:05:56 +0800 Yang Yingliang <[email protected]>…
Introduce a more general config for compile
kernel/irq/migration.c. Move theCONFIG_GENERIC_PENDING_IRQintomigration.c. So we can move other migration interrupts code intomigration.cwithout selectCONFIG_GENERIC_PENDING_IRQ.
Quoted 8 lines
Cc Jiang Liu <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Marc Zyngier <[email protected]>Cc Mark Rutland <[email protected]>Cc Will Deacon <[email protected]>Cc Russell King - ARM Linux <[email protected]>Cc Hanjun Guo <[email protected]>Signed-off-by Yang Yingliang <[email protected]>
M.
Signature · 1 line
Jazz is not dead. It just smells funny.
RFC PATCH v5 2/4 genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug
In reply to Yang YingliangAdd irq_migrate_all_off_this_cpu() into kernel/irq/migration.c. So we can use it to migrate interrupts, when cpu is offline.
--- include/linux/irq.h | 2 ++ kernel/irq/migration.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+)
include/linux/irq.h +2 -0
@@ -438,6 +438,8 @@ extern int irq_set_affinity_locked(struct irq_data *data, const struct cpumask *cpumask, bool force);extern int irq_set_vcpu_affinity (unsigned int irq,void *vcpu_info); +extern void irq_migrate_all_off_this_cpu (void ); +#if defined(CONFIG_SMP ) && defined(CONFIG_GENERIC_PENDING_IRQ )void irq_move_irq (struct irq_data *data);void irq_move_masked_irq (struct irq_data *data);
kernel/irq/migration.c +64 -0
73 lines not on this page · raw message
Signature · 1 line
2.5.0
Re: [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug
Quoted 11 lines · On Sat, 19 Sep 2015 11:05:57 +0800 Yang Yingliang <[email protected]>…
Add
irq_migrate_all_off_this_cpu()intokernel/irq/migration.c. So we can use it to migrate interrupts, when cpu is offline.Cc Jiang Liu <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Marc Zyngier <[email protected]>Cc Mark Rutland <[email protected]>Cc Will Deacon <[email protected]>Cc Russell King - ARM Linux <[email protected]>Cc Hanjun Guo <[email protected]>Signed-off-by Yang Yingliang <[email protected]>
M.
Signature · 1 line
Jazz is not dead. It just smells funny.
Re: [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug
In reply to Yang YingliangQuoted 1 line · Yang Yingliang
Add
irq_migrate_all_off_this_cpu()intokernel/irq/migration.c.
This doesn't make any sense at all.
You just reuse the existing file to stick your new code into it without reusing a single bit in that file. Aside of that it's unconditionally compiled, which means all existing users of CONFIG_GENERIC_PENDING_IRQ are burdened with pointless code.
The right thing to do is:
Add that code to a new file: kernel/irq/cpuhotplug.c and make that depend on CONFIG_GENERIC_IRQ_MIGRATION.
Thanks,
tglx
Re: [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug
Quoted 11 lines · Thomas Gleixner
Quoted 1 line · Yang Yingliang
Add
irq_migrate_all_off_this_cpu()intokernel/irq/migration.c.This doesn't make any sense at all.
You just reuse the existing file to stick your new code into it without reusing a single bit in that file. Aside of that it's unconditionally compiled, which means all existing users of
CONFIG_GENERIC_PENDING_IRQare burdened with pointless code.
Quoted 4 lines
The right thing to do is:
Add that code to a new file:
kernel/irq/cpuhotplug.cand make that depend onCONFIG_GENERIC_IRQ_MIGRATION.
How about add #ifdef CONFIG_CPU_HOTPLUG around new code in kernel/irq/migration.c ?
Thanks,
Yang
Re: [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug
Quoted 12 lines · Yang Yingliang
Quoted 11 lines · Thomas Gleixner
Quoted 1 line · Yang Yingliang
Add
irq_migrate_all_off_this_cpu()intokernel/irq/migration.c.This doesn't make any sense at all.
You just reuse the existing file to stick your new code into it without reusing a single bit in that file. Aside of that it's unconditionally compiled, which means all existing users of
CONFIG_GENERIC_PENDING_IRQare burdened with pointless code.
Quoted 7 lines
Quoted 4 lines
The right thing to do is:
Add that code to a new file:
kernel/irq/cpuhotplug.cand make that depend onCONFIG_GENERIC_IRQ_MIGRATION.How about add #ifdef
CONFIG_CPU_HOTPLUGaround new code inkernel/irq/migration.c?
What's the point? Just to have useless churn and ifdeffery in that file for nothing?
Thanks,
tglx
RFC PATCH v5 3/4 arm64: fix a migrating irq bug when hotplug cpu
In reply to Yang YingliangWhen cpu is disabled, all irqs will be migratged to another cpu. In some cases, a new affinity is different, it needed to be coppied to irq's affinity. But if the type of irq is LPI, it's affinity will not be coppied because of irq_set_affinity's return value. 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.
--- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/irq.h | 1 - arch/arm64/kernel/irq.c | 62 -------------------------------------------- arch/arm64/kernel/smp.c | 2 +- 4 files changed, 2 insertions(+), 64 deletions(-)
arch/arm64/Kconfig +1 -0
@@ -410,6 +410,7 @@ config NR_CPUS config HOTPLUG_CPU bool "Support for hot-pluggable CPUs" + select GENERIC_IRQ_MIGRATION help Say Y here to experiment with turning CPUs off and on. CPUs can be controlled through /sys/devices/system/cpu.
arch/arm64/include/asm/irq.h +0 -1
@@ -7,7 +7,6 @@struct pt_regs ; -extern void migrate_irqs (void );extern void set_handle_irq (void (*handle_irq)(struct pt_regs *));static inline void acpi_irq_init (void )
arch/arm64/kernel/irq.c +0 -62
71 lines not on this page · raw message
arch/arm64/kernel/smp.c +1 -1
@@ -232,7 +232,7 @@ int __cpu_disable(void)/* * OK - migrate IRQs away from this CPU */ -migrate_irqs (); +irq_migrate_all_off_this_cpu ();/* * Remove this CPU from the vm mask set of all processes.
Signature · 1 line
2.5.0
Re: [RFC PATCH v5 3/4] arm64: fix a migrating irq bug when hotplug cpu
Quoted 5 lines · On Sat, 19 Sep 2015 11:05:58 +0800 Yang Yingliang <[email protected]>…
When cpu is disabled, all irqs will be migratged to another cpu. In some cases, a new affinity is different, it needed to be coppied to irq's affinity. But if the type of irq is LPI, it's affinity will not be coppied because of irq_set_affinity's return value. Fix it by using
irq_do_set_affinity.
Nit: This hasn't much to do with LPIs proper, but with the fact that the architecture code only has a partial knowledge of the possible affinity setting return values.
Quoted 4 lines
And migrating interrupts is a core code matter, so use the generic function
irq_migrate_all_off_this_cpu()to migrate interrupts inkernel/irq/migration.c.
Quoted 8 lines
Cc Jiang Liu <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Marc Zyngier <[email protected]>Cc Mark Rutland <[email protected]>Cc Will Deacon <[email protected]>Cc Russell King - ARM Linux <[email protected]>Cc Hanjun Guo <[email protected]>Signed-off-by Yang Yingliang <[email protected]>
Otherwise Acked-by: Marc Zyngier <[email protected]>
M.
Signature · 1 line
Jazz is not dead. It just smells funny.
RFC PATCH v5 4/4 arm: fix a migrating irq bug when hotplug cpu
In reply to Yang YingliangWhen cpu is disabled, all irqs will be migratged to another cpu. In some cases, a new affinity is different, it needed to be coppied to irq's affinity. But if the type of irq is LPI, it's affinity will not be coppied because of irq_set_affinity's return value. 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.
--- arch/arm/Kconfig | 1 + arch/arm/include/asm/irq.h | 1 - arch/arm/kernel/irq.c | 62 ---------------------------------------------- arch/arm/kernel/smp.c | 2 +- 4 files changed, 2 insertions(+), 64 deletions(-)
arch/arm/Kconfig +1 -0
@@ -1492,6 +1492,7 @@ config NR_CPUS config HOTPLUG_CPU bool "Support for hot-pluggable CPUs" depends on SMP + select GENERIC_IRQ_MIGRATION help Say Y here to experiment with turning CPUs off and on. CPUs can be controlled through /sys/devices/system/cpu.
arch/arm/include/asm/irq.h +0 -1
@@ -24,7 +24,6 @@#ifndef __ASSEMBLY__struct irqaction ;struct pt_regs ; -extern void migrate_irqs (void );extern void asm_do_IRQ (unsigned int ,struct pt_regs *);void handle_IRQ (unsigned int ,struct pt_regs *);
arch/arm/kernel/irq.c +0 -62
71 lines not on this page · raw message
arch/arm/kernel/smp.c +1 -1
@@ -218,7 +218,7 @@ int __cpu_disable(void)/* * OK - migrate IRQs away from this CPU */ -migrate_irqs (); +irq_migrate_all_off_this_cpu ();/* * Flush user cache and TLB mappings, and then remove this CPU
Signature · 1 line
2.5.0
Re: [RFC PATCH v5 4/4] arm: fix a migrating irq bug when hotplug cpu
Quoted 10 lines · On Sat, 19 Sep 2015 11:05:59 +0800 Yang Yingliang <[email protected]>…
When cpu is disabled, all irqs will be migratged to another cpu. In some cases, a new affinity is different, it needed to be coppied to irq's affinity. But if the type of irq is LPI, it's affinity will not be coppied because of irq_set_affinity's return value. 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 inkernel/irq/migration.c.
Quoted 8 lines
Cc Jiang Liu <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Marc Zyngier <[email protected]>Cc Mark Rutland <[email protected]>Cc Will Deacon <[email protected]>Cc Russell King - ARM Linux <[email protected]>Cc Hanjun Guo <[email protected]>Signed-off-by Yang Yingliang <[email protected]>
M.
Signature · 1 line
Jazz is not dead. It just smells funny.
Quoted 21 lines · Yang Yingliang
----
Changes in v5:
- remove the macro that guardmove_irqs()
- use nameirq_migrate_all_off_this_cpuinstead ofmove_irqsChanges in v4:
- selectGENERIC_IRQ_MIGRATIONwhen configGENERIC_IRQ_MIGRATIONis enabled
- addmove_irqs()intokerne/irq/migration.cfor cpu hotplug
- usemove_irqs()to migrate interrupts on arm/arm64 when cpu is going to down
- split bugfix patch into seperate patches for arm and arm64Changes in v3:
- introduce configGENERIC_IRQ_MIGRATIONfor compilingmigration.c
- renamemigrate_irqsinarch/ia64/kernel/irq.cto avoid compiling errorChanges in v2:
- use the exiting helper to setIRQD_MOVE_PCNTXTflag
- usefor_each_active_irq()instead offor_each_irq_desc()
- add some warn messages when affinity is null or do set affinity failed
----
Quoted 8 lines
Hi All,
There is a bug:
When cpu is disabled, all irqs will be migratged to another cpu. In some cases, a new affinity is different, it needed to be coppied to irq's affinity. But if the type of irq is LPI, it's affinity will not be coppied because of irq_set_affinity's return value.
This series looks good to me:
Marc: once you're happy with the irq/core changes, feel free to include the arm64 patch in your tree.
Will