* [RFC PATCH v5 0/4] arm/arm64: fix a migrating irq bug when hotplug cpu
@ 2015-09-19 3:05 Yang Yingliang
2015-09-19 3:05 ` [RFC PATCH v5 1/4] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION Yang Yingliang
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Yang Yingliang @ 2015-09-19 3:05 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel
Cc: Yang Yingliang, Jiang Liu, Thomas Gleixner, Marc Zyngier,
Mark Rutland, Will Deacon, Russell King - ARM Linux, Hanjun Guo
----
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.
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Hanjun Guo <hanjun.guo@linaro.org>
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(-)
--
2.5.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [RFC PATCH v5 1/4] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION
2015-09-19 3:05 [RFC PATCH v5 0/4] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
@ 2015-09-19 3:05 ` Yang Yingliang
2015-09-22 18:49 ` Marc Zyngier
2015-09-19 3:05 ` [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug Yang Yingliang
` (3 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Yang Yingliang @ 2015-09-19 3:05 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel
Cc: Yang Yingliang, Jiang Liu, Thomas Gleixner, Marc Zyngier,
Mark Rutland, Will Deacon, Russell King - ARM Linux, Hanjun Guo
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.
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
kernel/irq/Kconfig | 5 +++++
kernel/irq/Makefile | 2 +-
kernel/irq/migration.c | 2 ++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index 9a76e3b..1ac0647 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -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
diff --git a/kernel/irq/Makefile b/kernel/irq/Makefile
index d121235..bdd31b7 100644
--- a/kernel/irq/Makefile
+++ b/kernel/irq/Makefile
@@ -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
diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c
index 37ddb7b..1ff2b77 100644
--- a/kernel/irq/migration.c
+++ b/kernel/irq/migration.c
@@ -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
--
2.5.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug
2015-09-19 3:05 [RFC PATCH v5 0/4] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
2015-09-19 3:05 ` [RFC PATCH v5 1/4] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION Yang Yingliang
@ 2015-09-19 3:05 ` Yang Yingliang
2015-09-22 18:48 ` Marc Zyngier
2015-09-22 18:54 ` Thomas Gleixner
2015-09-19 3:05 ` [RFC PATCH v5 3/4] arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
` (2 subsequent siblings)
4 siblings, 2 replies; 13+ messages in thread
From: Yang Yingliang @ 2015-09-19 3:05 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel
Cc: Yang Yingliang, Jiang Liu, Thomas Gleixner, Marc Zyngier,
Mark Rutland, Will Deacon, Russell King - ARM Linux, Hanjun Guo
Add irq_migrate_all_off_this_cpu() into kernel/irq/migration.c.
So we can use it to migrate interrupts, when cpu is offline.
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
include/linux/irq.h | 2 ++
kernel/irq/migration.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 6f8b340..c111fa1 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -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);
diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c
index 1ff2b77..6e3e38d 100644
--- a/kernel/irq/migration.c
+++ b/kernel/irq/migration.c
@@ -1,6 +1,7 @@
#include <linux/irq.h>
#include <linux/interrupt.h>
+#include <linux/ratelimit.h>
#include "internals.h"
@@ -79,3 +80,66 @@ void irq_move_irq(struct irq_data *idata)
idata->chip->irq_unmask(idata);
}
#endif
+
+static bool migrate_one_irq(struct irq_desc *desc)
+{
+ struct irq_data *d = irq_desc_get_irq_data(desc);
+ const struct cpumask *affinity = d->affinity;
+ struct irq_chip *c;
+ bool ret = false;
+
+ /*
+ * If this is a per-CPU interrupt, or the affinity does not
+ * include this CPU, then we have nothing to do.
+ */
+ if (irqd_is_per_cpu(d) || !cpumask_test_cpu(smp_processor_id(), affinity))
+ return false;
+
+ if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
+ affinity = cpu_online_mask;
+ ret = true;
+ }
+
+ c = irq_data_get_irq_chip(d);
+ if (!c->irq_set_affinity) {
+ pr_warn_ratelimited("IRQ%u: unable to set affinity\n", d->irq);
+ } else {
+ int r = irq_do_set_affinity(d, affinity, false);
+ if (r)
+ pr_warn_ratelimited("IRQ%u: set affinity failed(%d).\n", d->irq, r);
+ }
+
+ return ret;
+}
+
+/*
+ * The current CPU has been marked offline. Migrate IRQs off this CPU.
+ * If the affinity settings do not allow other CPUs, force them onto any
+ * available CPU.
+ *
+ * Note: we must iterate over all IRQs, whether they have an attached
+ * action structure or not, as we need to get chained interrupts too.
+ */
+void irq_migrate_all_off_this_cpu(void)
+{
+ unsigned int irq;
+ struct irq_desc *desc;
+ unsigned long flags;
+
+ local_irq_save(flags);
+
+ for_each_active_irq(irq) {
+ bool affinity_broken;
+
+ desc = irq_to_desc(irq);
+ raw_spin_lock(&desc->lock);
+ affinity_broken = migrate_one_irq(desc);
+ raw_spin_unlock(&desc->lock);
+
+ if (affinity_broken)
+ pr_warn_ratelimited("IRQ%u no longer affine to CPU%u\n",
+ irq, smp_processor_id());
+ }
+
+ local_irq_restore(flags);
+}
--
2.5.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RFC PATCH v5 3/4] arm64: fix a migrating irq bug when hotplug cpu
2015-09-19 3:05 [RFC PATCH v5 0/4] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
2015-09-19 3:05 ` [RFC PATCH v5 1/4] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION Yang Yingliang
2015-09-19 3:05 ` [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug Yang Yingliang
@ 2015-09-19 3:05 ` Yang Yingliang
2015-09-22 18:44 ` Marc Zyngier
2015-09-19 3:05 ` [RFC PATCH v5 4/4] arm: " Yang Yingliang
2015-09-22 18:34 ` [RFC PATCH v5 0/4] arm/arm64: " Will Deacon
4 siblings, 1 reply; 13+ messages in thread
From: Yang Yingliang @ 2015-09-19 3:05 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel
Cc: Yang Yingliang, Jiang Liu, Thomas Gleixner, Marc Zyngier,
Mark Rutland, Will Deacon, Russell King - ARM Linux, Hanjun Guo
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 in
kernel/irq/migration.c.
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
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(-)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 7d95663..e0cac17 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -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.
diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h
index bbb251b..0916929 100644
--- a/arch/arm64/include/asm/irq.h
+++ b/arch/arm64/include/asm/irq.h
@@ -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)
diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c
index 11dc3fd..9f17ec0 100644
--- a/arch/arm64/kernel/irq.c
+++ b/arch/arm64/kernel/irq.c
@@ -27,7 +27,6 @@
#include <linux/init.h>
#include <linux/irqchip.h>
#include <linux/seq_file.h>
-#include <linux/ratelimit.h>
unsigned long irq_err_count;
@@ -54,64 +53,3 @@ void __init init_IRQ(void)
if (!handle_arch_irq)
panic("No interrupt controller found.");
}
-
-#ifdef CONFIG_HOTPLUG_CPU
-static bool migrate_one_irq(struct irq_desc *desc)
-{
- struct irq_data *d = irq_desc_get_irq_data(desc);
- const struct cpumask *affinity = irq_data_get_affinity_mask(d);
- struct irq_chip *c;
- bool ret = false;
-
- /*
- * If this is a per-CPU interrupt, or the affinity does not
- * include this CPU, then we have nothing to do.
- */
- if (irqd_is_per_cpu(d) || !cpumask_test_cpu(smp_processor_id(), affinity))
- return false;
-
- if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
- affinity = cpu_online_mask;
- ret = true;
- }
-
- c = irq_data_get_irq_chip(d);
- if (!c->irq_set_affinity)
- pr_debug("IRQ%u: unable to set affinity\n", d->irq);
- else if (c->irq_set_affinity(d, affinity, false) == IRQ_SET_MASK_OK && ret)
- cpumask_copy(irq_data_get_affinity_mask(d), affinity);
-
- return ret;
-}
-
-/*
- * The current CPU has been marked offline. Migrate IRQs off this CPU.
- * If the affinity settings do not allow other CPUs, force them onto any
- * available CPU.
- *
- * Note: we must iterate over all IRQs, whether they have an attached
- * action structure or not, as we need to get chained interrupts too.
- */
-void migrate_irqs(void)
-{
- unsigned int i;
- struct irq_desc *desc;
- unsigned long flags;
-
- local_irq_save(flags);
-
- for_each_irq_desc(i, desc) {
- bool affinity_broken;
-
- raw_spin_lock(&desc->lock);
- affinity_broken = migrate_one_irq(desc);
- raw_spin_unlock(&desc->lock);
-
- if (affinity_broken)
- pr_warn_ratelimited("IRQ%u no longer affine to CPU%u\n",
- i, smp_processor_id());
- }
-
- local_irq_restore(flags);
-}
-#endif /* CONFIG_HOTPLUG_CPU */
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index dbdaacd..ee5cafa 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -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.
--
2.5.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RFC PATCH v5 4/4] arm: fix a migrating irq bug when hotplug cpu
2015-09-19 3:05 [RFC PATCH v5 0/4] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
` (2 preceding siblings ...)
2015-09-19 3:05 ` [RFC PATCH v5 3/4] arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
@ 2015-09-19 3:05 ` Yang Yingliang
2015-09-22 18:50 ` Marc Zyngier
2015-09-22 18:34 ` [RFC PATCH v5 0/4] arm/arm64: " Will Deacon
4 siblings, 1 reply; 13+ messages in thread
From: Yang Yingliang @ 2015-09-19 3:05 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel
Cc: Yang Yingliang, Jiang Liu, Thomas Gleixner, Marc Zyngier,
Mark Rutland, Will Deacon, Russell King - ARM Linux, Hanjun Guo
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 in
kernel/irq/migration.c.
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
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(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 72ad724..bffba78 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -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.
diff --git a/arch/arm/include/asm/irq.h b/arch/arm/include/asm/irq.h
index be1d07d..882bf98 100644
--- a/arch/arm/include/asm/irq.h
+++ b/arch/arm/include/asm/irq.h
@@ -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 *);
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index 5ff4826..78abea8 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -31,7 +31,6 @@
#include <linux/smp.h>
#include <linux/init.h>
#include <linux/seq_file.h>
-#include <linux/ratelimit.h>
#include <linux/errno.h>
#include <linux/list.h>
#include <linux/kallsyms.h>
@@ -136,64 +135,3 @@ int __init arch_probe_nr_irqs(void)
return nr_irqs;
}
#endif
-
-#ifdef CONFIG_HOTPLUG_CPU
-static bool migrate_one_irq(struct irq_desc *desc)
-{
- struct irq_data *d = irq_desc_get_irq_data(desc);
- const struct cpumask *affinity = irq_data_get_affinity_mask(d);
- struct irq_chip *c;
- bool ret = false;
-
- /*
- * If this is a per-CPU interrupt, or the affinity does not
- * include this CPU, then we have nothing to do.
- */
- if (irqd_is_per_cpu(d) || !cpumask_test_cpu(smp_processor_id(), affinity))
- return false;
-
- if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
- affinity = cpu_online_mask;
- ret = true;
- }
-
- c = irq_data_get_irq_chip(d);
- if (!c->irq_set_affinity)
- pr_debug("IRQ%u: unable to set affinity\n", d->irq);
- else if (c->irq_set_affinity(d, affinity, false) == IRQ_SET_MASK_OK && ret)
- cpumask_copy(irq_data_get_affinity_mask(d), affinity);
-
- return ret;
-}
-
-/*
- * The current CPU has been marked offline. Migrate IRQs off this CPU.
- * If the affinity settings do not allow other CPUs, force them onto any
- * available CPU.
- *
- * Note: we must iterate over all IRQs, whether they have an attached
- * action structure or not, as we need to get chained interrupts too.
- */
-void migrate_irqs(void)
-{
- unsigned int i;
- struct irq_desc *desc;
- unsigned long flags;
-
- local_irq_save(flags);
-
- for_each_irq_desc(i, desc) {
- bool affinity_broken;
-
- raw_spin_lock(&desc->lock);
- affinity_broken = migrate_one_irq(desc);
- raw_spin_unlock(&desc->lock);
-
- if (affinity_broken)
- pr_warn_ratelimited("IRQ%u no longer affine to CPU%u\n",
- i, smp_processor_id());
- }
-
- local_irq_restore(flags);
-}
-#endif /* CONFIG_HOTPLUG_CPU */
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 48185a7..fc26384 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -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
--
2.5.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [RFC PATCH v5 0/4] arm/arm64: fix a migrating irq bug when hotplug cpu
2015-09-19 3:05 [RFC PATCH v5 0/4] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
` (3 preceding siblings ...)
2015-09-19 3:05 ` [RFC PATCH v5 4/4] arm: " Yang Yingliang
@ 2015-09-22 18:34 ` Will Deacon
4 siblings, 0 replies; 13+ messages in thread
From: Will Deacon @ 2015-09-22 18:34 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-arm-kernel, linux-kernel, Jiang Liu, Thomas Gleixner,
Marc Zyngier, Mark Rutland, Russell King - ARM Linux, hanjun.guo
On Sat, Sep 19, 2015 at 04:05:55AM +0100, Yang Yingliang wrote:
> ----
> 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.
This series looks good to me:
Reviewed-by: Will Deacon <will.deacon@arm.com>
Marc: once you're happy with the irq/core changes, feel free to include
the arm64 patch in your tree.
Will
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH v5 3/4] arm64: fix a migrating irq bug when hotplug cpu
2015-09-19 3:05 ` [RFC PATCH v5 3/4] arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
@ 2015-09-22 18:44 ` Marc Zyngier
0 siblings, 0 replies; 13+ messages in thread
From: Marc Zyngier @ 2015-09-22 18:44 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-arm-kernel, linux-kernel, Jiang Liu, Thomas Gleixner,
Mark Rutland, Will Deacon, Russell King - ARM Linux, Hanjun Guo
On Sat, 19 Sep 2015 11:05:58 +0800
Yang Yingliang <yangyingliang@huawei.com> wrote:
> 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.
> 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 <jiang.liu@linux.intel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
> Cc: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Otherwise Acked-by: Marc Zyngier <marc.zyngier@arm.com>
M.
--
Jazz is not dead. It just smells funny.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug
2015-09-19 3:05 ` [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug Yang Yingliang
@ 2015-09-22 18:48 ` Marc Zyngier
2015-09-22 18:54 ` Thomas Gleixner
1 sibling, 0 replies; 13+ messages in thread
From: Marc Zyngier @ 2015-09-22 18:48 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-arm-kernel, linux-kernel, Jiang Liu, Thomas Gleixner,
Mark Rutland, Will Deacon, Russell King - ARM Linux, Hanjun Guo
On Sat, 19 Sep 2015 11:05:57 +0800
Yang Yingliang <yangyingliang@huawei.com> wrote:
> Add irq_migrate_all_off_this_cpu() into kernel/irq/migration.c.
> So we can use it to migrate interrupts, when cpu is offline.
>
> Cc: Jiang Liu <jiang.liu@linux.intel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
> Cc: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
M.
--
Jazz is not dead. It just smells funny.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH v5 1/4] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION
2015-09-19 3:05 ` [RFC PATCH v5 1/4] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION Yang Yingliang
@ 2015-09-22 18:49 ` Marc Zyngier
0 siblings, 0 replies; 13+ messages in thread
From: Marc Zyngier @ 2015-09-22 18:49 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-arm-kernel, linux-kernel, Jiang Liu, Thomas Gleixner,
Mark Rutland, Will Deacon, Russell King - ARM Linux, Hanjun Guo
On Sat, 19 Sep 2015 11:05:56 +0800
Yang Yingliang <yangyingliang@huawei.com> wrote:
> 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.
>
> Cc: Jiang Liu <jiang.liu@linux.intel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
> Cc: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
M.
--
Jazz is not dead. It just smells funny.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH v5 4/4] arm: fix a migrating irq bug when hotplug cpu
2015-09-19 3:05 ` [RFC PATCH v5 4/4] arm: " Yang Yingliang
@ 2015-09-22 18:50 ` Marc Zyngier
0 siblings, 0 replies; 13+ messages in thread
From: Marc Zyngier @ 2015-09-22 18:50 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-arm-kernel, linux-kernel, Jiang Liu, Thomas Gleixner,
Mark Rutland, Will Deacon, Russell King - ARM Linux, Hanjun Guo
On Sat, 19 Sep 2015 11:05:59 +0800
Yang Yingliang <yangyingliang@huawei.com> wrote:
> 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 in
> kernel/irq/migration.c.
>
> Cc: Jiang Liu <jiang.liu@linux.intel.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
> Cc: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
M.
--
Jazz is not dead. It just smells funny.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug
2015-09-19 3:05 ` [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug Yang Yingliang
2015-09-22 18:48 ` Marc Zyngier
@ 2015-09-22 18:54 ` Thomas Gleixner
2015-09-23 4:16 ` Yang Yingliang
1 sibling, 1 reply; 13+ messages in thread
From: Thomas Gleixner @ 2015-09-22 18:54 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-arm-kernel, linux-kernel, Jiang Liu, Marc Zyngier,
Mark Rutland, Will Deacon, Russell King - ARM Linux, Hanjun Guo
On Sat, 19 Sep 2015, Yang Yingliang wrote:
> Add irq_migrate_all_off_this_cpu() into kernel/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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug
2015-09-22 18:54 ` Thomas Gleixner
@ 2015-09-23 4:16 ` Yang Yingliang
2015-09-23 8:02 ` Thomas Gleixner
0 siblings, 1 reply; 13+ messages in thread
From: Yang Yingliang @ 2015-09-23 4:16 UTC (permalink / raw)
To: Thomas Gleixner
Cc: linux-arm-kernel, linux-kernel, Jiang Liu, Marc Zyngier,
Mark Rutland, Will Deacon, Russell King - ARM Linux, Hanjun Guo
On 2015/9/23 2:54, Thomas Gleixner wrote:
> On Sat, 19 Sep 2015, Yang Yingliang wrote:
>
>> Add irq_migrate_all_off_this_cpu() into kernel/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.
How about add #ifdef CONFIG_CPU_HOTPLUG around new code
in kernel/irq/migration.c ?
Thanks,
Yang
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug
2015-09-23 4:16 ` Yang Yingliang
@ 2015-09-23 8:02 ` Thomas Gleixner
0 siblings, 0 replies; 13+ messages in thread
From: Thomas Gleixner @ 2015-09-23 8:02 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-arm-kernel, linux-kernel, Jiang Liu, Marc Zyngier,
Mark Rutland, Will Deacon, Russell King - ARM Linux, Hanjun Guo
On Wed, 23 Sep 2015, Yang Yingliang wrote:
> On 2015/9/23 2:54, Thomas Gleixner wrote:
> > On Sat, 19 Sep 2015, Yang Yingliang wrote:
> >
> > > Add irq_migrate_all_off_this_cpu() into kernel/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.
>
> How about add #ifdef CONFIG_CPU_HOTPLUG around new code
> in kernel/irq/migration.c ?
What's the point? Just to have useless churn and ifdeffery in that
file for nothing?
Thanks,
tglx
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-09-23 8:03 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-19 3:05 [RFC PATCH v5 0/4] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
2015-09-19 3:05 ` [RFC PATCH v5 1/4] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION Yang Yingliang
2015-09-22 18:49 ` Marc Zyngier
2015-09-19 3:05 ` [RFC PATCH v5 2/4] genirq: add irq_migrate_all_off_this_cpu() for cpu hotplug Yang Yingliang
2015-09-22 18:48 ` Marc Zyngier
2015-09-22 18:54 ` Thomas Gleixner
2015-09-23 4:16 ` Yang Yingliang
2015-09-23 8:02 ` Thomas Gleixner
2015-09-19 3:05 ` [RFC PATCH v5 3/4] arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
2015-09-22 18:44 ` Marc Zyngier
2015-09-19 3:05 ` [RFC PATCH v5 4/4] arm: " Yang Yingliang
2015-09-22 18:50 ` Marc Zyngier
2015-09-22 18:34 ` [RFC PATCH v5 0/4] arm/arm64: " Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).