arm/arm64: fix a migrating irq bug when hotplug cpu
Subsystems (3)
v4 cover arm/arm64: fix a migrating irq bug when hotplug cpu
----
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 move_irqs() 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 | 4 +++ kernel/irq/Kconfig | 5 ++++ kernel/irq/Makefile | 2 +- kernel/irq/migration.c | 68 ++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 82 insertions(+), 129 deletions(-)
Signature · 1 line
2.5.0
RFC PATCH v4 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
RFC PATCH v4 2/4 genirq: add move_irqs() for cpu hotplug
In reply to Yang YingliangAdd move_irqs() into kernel/irq/migration.c.
So we can use it to migrate interrupts, when
cpu is offline.
--- include/linux/irq.h | 4 +++ kernel/irq/migration.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+)
include/linux/irq.h +4 -0
@@ -446,6 +446,10 @@ static inline void irq_move_irq(struct irq_data *data) { }static inline void irq_move_masked_irq (struct irq_data *data) { }#endif +#if defined(CONFIG_SMP ) && defined(CONFIG_GENERIC_IRQ_MIGRATION ) && defined(CONFIG_HOTPLUG_CPU ) +void move_irqs (void ); +#endif +extern int no_irq_affinity;#ifdef CONFIG_HARDIRQS_SW_RESEND
kernel/irq/migration.c +66 -0
75 lines not on this page · raw message
Signature · 1 line
2.5.0
Re: [RFC PATCH v4 2/4] genirq: add move_irqs() for cpu hotplug
Quoted 22 lines · Yang Yingliang
Add
move_irqs()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]>--- include/linux/irq.h | 4 +++ kernel/irq/migration.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+)include/linux/irq.h +0
-0
include/linux/irq.h static inline void irq_move_irq(struct irq_data *data) { } · line 452
Quoted 7 lines
include/linux/irq.h +4
-0@@ -446,6 +446,10 @@ static inline void irq_move_irq(struct irq_data *data) { }static inline void irq_move_masked_irq (struct irq_data *data) { }#endif +#if defined(CONFIG_SMP ) && defined(CONFIG_GENERIC_IRQ_MIGRATION ) && defined(CONFIG_HOTPLUG_CPU ) +void move_irqs (void ); +#endif +
I don't think having this prototype guarded by this #if is very useful. You can probably leave it standalone.
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Re: [RFC PATCH v4 2/4] genirq: add move_irqs() for cpu hotplug
Quoted 26 lines · Marc Zyngier
Quoted 25 lines · Yang Yingliang
Add
move_irqs()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]>--- include/linux/irq.h | 4 +++ kernel/irq/migration.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+)include/linux/irq.h +0
-0@@ -446,6 +446,10 @@ static inline void irq_move_irq(struct irq_data *data) { }static inline void irq_move_masked_irq (struct irq_data *data) { }#endif
Quoted 7 lines
include/linux/irq.h static inline void irq_move_irq(struct irq_data *data) { } · line 452
Quoted 4 lines
include/linux/irq.h +4
-0+#if defined(CONFIG_SMP ) && defined(CONFIG_GENERIC_IRQ_MIGRATION ) && defined(CONFIG_HOTPLUG_CPU ) +void move_irqs (void ); +#endif +I don't think having this prototype guarded by this #if is very useful. You can probably leave it standalone.
Yes, there is no point if the function name is unique. Though move_irqs() is rather undescriptive. irq_break_affinities() might describe it quite well, but feel free to come up with soemthing better.
Thanks,
tglx
Re: [RFC PATCH v4 2/4] genirq: add move_irqs() for cpu hotplug
Quoted 7 lines · Thomas Gleixner
Quoted 2 lines · Marc Zyngier
I don't think having this prototype guarded by this #if is very useful. You can probably leave it standalone.
Yes, there is no point if the function name is unique. Though
move_irqs()is rather undescriptive.irq_break_affinities()might describe it quite well, but feel free to come up with soemthing better.
I don't think "irq_break_affinities" is anywhere near a good name - it's not about always breaking affinities (moving an IRQ off one CPU onto another within the current affinity setting does not break the affinity.)
irq_migrate_all()
irq_migrate_all_off_this_cpu()
irq_this_cpu_hotunplug()
irq_cpu_hotunplug()
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
Re: [RFC PATCH v4 2/4] genirq: add move_irqs() for cpu hotplug
Quoted 13 lines · Russell King - ARM Linux
Quoted 7 lines · Thomas Gleixner
Quoted 2 lines · Marc Zyngier
I don't think having this prototype guarded by this #if is very useful. You can probably leave it standalone.
Yes, there is no point if the function name is unique. Though
move_irqs()is rather undescriptive.irq_break_affinities()might describe it quite well, but feel free to come up with soemthing better.I don't think "
irq_break_affinities" is anywhere near a good name - it's not about always breaking affinities (moving an IRQ off one CPU onto another within the current affinity setting does not break the affinity.)
Quoted 8 lines
irq_migrate_all()
irq_migrate_all_off_this_cpu()
irq_this_cpu_hotunplug()
irq_cpu_hotunplug()
irq_migrate_all_off_this_cpu() describe it well, I will choose it.
Thanks,
Yang
RFC PATCH v4 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 move_irqs() 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 (); +move_irqs ();/* * Remove this CPU from the vm mask set of all processes.
Signature · 1 line
2.5.0
Re: [RFC PATCH v4 3/4] arm64: fix a migrating irq bug when hotplug cpu
Quoted 17 lines · Yang Yingliang
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
move_irqs()to migrate interrupts inkernel/irq/migration.c.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]>
Quoted 6 lines
--- 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(-)
Removing code is always good, so:
but obviously this depends on the core stuff.
Will
RFC PATCH v4 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 move_irqs() 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 (); +move_irqs ();/* * Flush user cache and TLB mappings, and then remove this CPU
Signature · 1 line
2.5.0
On Thu, 17 Sep 2015, Yang Yingliang wrote:
Can you please Cc the relevant people on the cover letter as well next time?
Thanks,
tglx
Quoted 10 lines · Thomas Gleixner
On Thu, 17 Sep 2015, Yang Yingliang wrote:
Can you please Cc the relevant people on the cover letter as well next time?
Thanks,
tglx
OK, I will add Cc next time.
Thanks,
Yang