* [RFC PATCH v3 0/3] arm/arm64: fix a migrating irq bug when hotplug cpu
@ 2015-09-16 3:58 Yang Yingliang
2015-09-16 3:58 ` [RFC PATCH v3 1/3] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION Yang Yingliang
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Yang Yingliang @ 2015-09-16 3:58 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 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. On ia64, there is a migrate_irqs() in arch/ia64/kernel/irq.c,
rename it to avoid compiling error.
With the above preparation, move the migrating interrupts code into kernel/irq/migration.c
and fix the bug by using irq_do_set_affinity().
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 (3):
genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION
ia64: rename migrate_irqs() to avoid compiling error
arm/arm64: fix a migrating irq bug when hotplug cpu
arch/arc/Kconfig | 1 +
arch/arm/Kconfig | 1 +
arch/arm/include/asm/irq.h | 1 -
arch/arm/kernel/irq.c | 62 ----------------------------------------
arch/arm64/Kconfig | 1 +
arch/arm64/include/asm/irq.h | 1 -
arch/arm64/kernel/irq.c | 62 ----------------------------------------
arch/hexagon/Kconfig | 1 +
arch/ia64/Kconfig | 1 +
arch/ia64/kernel/irq.c | 4 +--
arch/tile/Kconfig | 1 +
arch/x86/Kconfig | 1 +
include/linux/irq.h | 4 +++
kernel/irq/Kconfig | 4 +++
kernel/irq/Makefile | 2 +-
kernel/irq/migration.c | 68 ++++++++++++++++++++++++++++++++++++++++++++
16 files changed, 86 insertions(+), 129 deletions(-)
--
2.5.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC PATCH v3 1/3] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION
2015-09-16 3:58 [RFC PATCH v3 0/3] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
@ 2015-09-16 3:58 ` Yang Yingliang
2015-09-16 8:13 ` Thomas Gleixner
2015-09-16 3:58 ` [RFC PATCH v3 2/3] ia64: rename migrate_irqs() to avoid compiling error Yang Yingliang
2015-09-16 3:58 ` [RFC PATCH v3 3/3] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
2 siblings, 1 reply; 10+ messages in thread
From: Yang Yingliang @ 2015-09-16 3:58 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>
---
arch/arc/Kconfig | 1 +
arch/hexagon/Kconfig | 1 +
arch/ia64/Kconfig | 1 +
arch/tile/Kconfig | 1 +
arch/x86/Kconfig | 1 +
kernel/irq/Kconfig | 4 ++++
kernel/irq/Makefile | 2 +-
kernel/irq/migration.c | 2 ++
8 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 78c0621..4133070 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -20,6 +20,7 @@ config ARC
# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
select GENERIC_IRQ_SHOW
select GENERIC_PENDING_IRQ if SMP
+ select GENERIC_IRQ_MIGRATION if SMP
select GENERIC_SMP_IDLE_THREAD
select HAVE_ARCH_KGDB
select HAVE_ARCH_TRACEHOOK
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index 4dc89d1..18d3255 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -12,6 +12,7 @@ config HEXAGON
# select ARCH_REQUIRE_GPIOLIB
# select HAVE_CLK
# select GENERIC_PENDING_IRQ if SMP
+ # select GENERIC_IRQ_MIGRATION if SMP
select GENERIC_ATOMIC64
select HAVE_PERF_EVENTS
# GENERIC_ALLOCATOR is used by dma_alloc_coherent()
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index eb0249e..e48c2c8 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -37,6 +37,7 @@ config IA64
select ARCH_DISCARD_MEMBLOCK
select GENERIC_IRQ_PROBE
select GENERIC_PENDING_IRQ if SMP
+ select GENERIC_IRQ_MIGRATION if SMP
select GENERIC_IRQ_SHOW
select GENERIC_IRQ_LEGACY
select ARCH_WANT_OPTIONAL_GPIOLIB
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 106c21b..bf8b059 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -14,6 +14,7 @@ config TILE
select HAVE_DEBUG_KMEMLEAK
select GENERIC_IRQ_PROBE
select GENERIC_PENDING_IRQ if SMP
+ select GENERIC_IRQ_MIGRATION if SMP
select GENERIC_IRQ_SHOW
select HAVE_DEBUG_BUGVERBOSE
select VIRT_TO_BUS
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 7aef2d5..a217a23 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -68,6 +68,7 @@ config X86
select GENERIC_IRQ_PROBE
select GENERIC_IRQ_SHOW
select GENERIC_PENDING_IRQ if SMP
+ select GENERIC_IRQ_MIGRATION if SMP
select GENERIC_SMP_IDLE_THREAD
select GENERIC_STRNCPY_FROM_USER
select GENERIC_STRNLEN_USER
diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index 9a76e3b..530c54a 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -30,6 +30,10 @@ config GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
config GENERIC_PENDING_IRQ
bool
+# Support for generic irq migration
+config GENERIC_IRQ_MIGRATION
+ bool
+
# Alpha specific irq affinity mechanism
config AUTO_IRQ_AFFINITY
bool
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] 10+ messages in thread
* [RFC PATCH v3 2/3] ia64: rename migrate_irqs() to avoid compiling error
2015-09-16 3:58 [RFC PATCH v3 0/3] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
2015-09-16 3:58 ` [RFC PATCH v3 1/3] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION Yang Yingliang
@ 2015-09-16 3:58 ` Yang Yingliang
2015-09-16 8:21 ` Thomas Gleixner
2015-09-16 3:58 ` [RFC PATCH v3 3/3] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
2 siblings, 1 reply; 10+ messages in thread
From: Yang Yingliang @ 2015-09-16 3:58 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
To avoid multi-declaration error after adding migrate_irqs into
kernel/irq/migration.c, rename migrate_irqs() to move_irqs().
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/ia64/kernel/irq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/ia64/kernel/irq.c b/arch/ia64/kernel/irq.c
index de4fc00..005f339 100644
--- a/arch/ia64/kernel/irq.c
+++ b/arch/ia64/kernel/irq.c
@@ -98,7 +98,7 @@ unsigned int vectors_in_migration[NR_IRQS];
* Since cpu_online_mask is already updated, we just need to check for
* affinity that has zeros
*/
-static void migrate_irqs(void)
+static void move_irqs(void)
{
int irq, new_cpu;
@@ -167,7 +167,7 @@ void fixup_irqs(void)
* Phase 1: Locate IRQs bound to this cpu and
* relocate them for cpu removal.
*/
- migrate_irqs();
+ move_irqs();
/*
* Phase 2: Perform interrupt processing for all entries reported in
--
2.5.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC PATCH v3 3/3] arm/arm64: fix a migrating irq bug when hotplug cpu
2015-09-16 3:58 [RFC PATCH v3 0/3] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
2015-09-16 3:58 ` [RFC PATCH v3 1/3] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION Yang Yingliang
2015-09-16 3:58 ` [RFC PATCH v3 2/3] ia64: rename migrate_irqs() to avoid compiling error Yang Yingliang
@ 2015-09-16 3:58 ` Yang Yingliang
2015-09-16 8:21 ` Thomas Gleixner
2 siblings, 1 reply; 10+ messages in thread
From: Yang Yingliang @ 2015-09-16 3:58 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 move the code to
kernel/irq/migration.c and select CONFIG_GENERIC_IRQ_MIGRATION when
CONFIG_HOTPLUG_CPU and CONFIG_SMP is enabled.
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/arm64/Kconfig | 1 +
arch/arm64/include/asm/irq.h | 1 -
arch/arm64/kernel/irq.c | 62 -----------------------------------------
include/linux/irq.h | 4 +++
kernel/irq/migration.c | 66 ++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 72 insertions(+), 126 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 72ad724..d70ddd5 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -22,6 +22,7 @@ config ARM
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
select GENERIC_IDLE_POLL_SETUP
select GENERIC_IRQ_PROBE
+ select GENERIC_IRQ_MIGRATION if SMP && HOTPLUG_CPU
select GENERIC_IRQ_SHOW
select GENERIC_IRQ_SHOW_LEVEL
select GENERIC_PCI_IOMAP
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/arm64/Kconfig b/arch/arm64/Kconfig
index 7d95663..70d5b23 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -33,6 +33,7 @@ config ARM64
select GENERIC_CPU_AUTOPROBE
select GENERIC_EARLY_IOREMAP
select GENERIC_IRQ_PROBE
+ select GENERIC_IRQ_MIGRATION if SMP && HOTPLUG_CPU
select GENERIC_IRQ_SHOW
select GENERIC_IRQ_SHOW_LEVEL
select GENERIC_PCI_IOMAP
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/include/linux/irq.h b/include/linux/irq.h
index 6f8b340..59e5e52 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -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 migrate_irqs(void);
+#endif
+
extern int no_irq_affinity;
#ifdef CONFIG_HARDIRQS_SW_RESEND
diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c
index 1ff2b77..89c9765 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,68 @@ void irq_move_irq(struct irq_data *idata)
idata->chip->irq_unmask(idata);
}
#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 = 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 migrate_irqs(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);
+}
+#endif /* CONFIG_HOTPLUG_CPU */
--
2.5.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v3 1/3] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION
2015-09-16 3:58 ` [RFC PATCH v3 1/3] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION Yang Yingliang
@ 2015-09-16 8:13 ` Thomas Gleixner
2015-09-16 11:07 ` Yang Yingliang
0 siblings, 1 reply; 10+ messages in thread
From: Thomas Gleixner @ 2015-09-16 8:13 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, 16 Sep 2015, Yang Yingliang wrote:
> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
> index 78c0621..4133070 100644
> --- a/arch/arc/Kconfig
> +++ b/arch/arc/Kconfig
> @@ -20,6 +20,7 @@ config ARC
> # for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
> select GENERIC_IRQ_SHOW
> select GENERIC_PENDING_IRQ if SMP
> + select GENERIC_IRQ_MIGRATION if SMP
What's the point of this?
> --- a/kernel/irq/Kconfig
> +++ b/kernel/irq/Kconfig
> @@ -30,6 +30,10 @@ config GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
> config GENERIC_PENDING_IRQ
> bool
+ select GENERIC_IRQ_MIGRATION
Will do it automatically without touching any of the arch Kconfig
files.
Thanks,
tglx
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v3 2/3] ia64: rename migrate_irqs() to avoid compiling error
2015-09-16 3:58 ` [RFC PATCH v3 2/3] ia64: rename migrate_irqs() to avoid compiling error Yang Yingliang
@ 2015-09-16 8:21 ` Thomas Gleixner
2015-09-16 11:13 ` Yang Yingliang
0 siblings, 1 reply; 10+ messages in thread
From: Thomas Gleixner @ 2015-09-16 8:21 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, 16 Sep 2015, Yang Yingliang wrote:
> To avoid multi-declaration error after adding migrate_irqs into
> kernel/irq/migration.c, rename migrate_irqs() to move_irqs().
And why can't you chose a different name for the generic function
instead of creating useless churn in IA64?
Thanks,
tglx
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v3 3/3] arm/arm64: fix a migrating irq bug when hotplug cpu
2015-09-16 3:58 ` [RFC PATCH v3 3/3] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
@ 2015-09-16 8:21 ` Thomas Gleixner
2015-09-16 11:15 ` Yang Yingliang
0 siblings, 1 reply; 10+ messages in thread
From: Thomas Gleixner @ 2015-09-16 8:21 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, 16 Sep 2015, Yang Yingliang wrote:
> arch/arm/Kconfig | 1 +
> arch/arm/include/asm/irq.h | 1 -
> arch/arm/kernel/irq.c | 62 -----------------------------------------
> arch/arm64/Kconfig | 1 +
> arch/arm64/include/asm/irq.h | 1 -
> arch/arm64/kernel/irq.c | 62 -----------------------------------------
> include/linux/irq.h | 4 +++
> kernel/irq/migration.c | 66 ++++++++++++++++++++++++++++++++++++++++++++
This want's to be split into seperate patches:
#1 Provide the core infrastructure
#2 Switch ARM to use it
#3 Switch ARM64 to use it
Thanks,
tglx
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v3 1/3] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION
2015-09-16 8:13 ` Thomas Gleixner
@ 2015-09-16 11:07 ` Yang Yingliang
0 siblings, 0 replies; 10+ messages in thread
From: Yang Yingliang @ 2015-09-16 11:07 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/16 16:13, Thomas Gleixner wrote:
> On Wed, 16 Sep 2015, Yang Yingliang wrote:
>> diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
>> index 78c0621..4133070 100644
>> --- a/arch/arc/Kconfig
>> +++ b/arch/arc/Kconfig
>> @@ -20,6 +20,7 @@ config ARC
>> # for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
>> select GENERIC_IRQ_SHOW
>> select GENERIC_PENDING_IRQ if SMP
>> + select GENERIC_IRQ_MIGRATION if SMP
>
> What's the point of this?
>
>> --- a/kernel/irq/Kconfig
>> +++ b/kernel/irq/Kconfig
>> @@ -30,6 +30,10 @@ config GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
>> config GENERIC_PENDING_IRQ
>> bool
>
> + select GENERIC_IRQ_MIGRATION
>
> Will do it automatically without touching any of the arch Kconfig
> files.
Your way is better, I will use this method.
Thanks,
Yang
>
> Thanks,
>
> tglx
>
> .
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v3 2/3] ia64: rename migrate_irqs() to avoid compiling error
2015-09-16 8:21 ` Thomas Gleixner
@ 2015-09-16 11:13 ` Yang Yingliang
0 siblings, 0 replies; 10+ messages in thread
From: Yang Yingliang @ 2015-09-16 11:13 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/16 16:21, Thomas Gleixner wrote:
> On Wed, 16 Sep 2015, Yang Yingliang wrote:
>
>> To avoid multi-declaration error after adding migrate_irqs into
>> kernel/irq/migration.c, rename migrate_irqs() to move_irqs().
>
> And why can't you chose a different name for the generic function
> instead of creating useless churn in IA64?
I am not sure which way is better at first. Never mind, I will chose a
new name for the generic function.
Thanks,
Yang
>
> Thanks,
>
> tglx
>
> .
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH v3 3/3] arm/arm64: fix a migrating irq bug when hotplug cpu
2015-09-16 8:21 ` Thomas Gleixner
@ 2015-09-16 11:15 ` Yang Yingliang
0 siblings, 0 replies; 10+ messages in thread
From: Yang Yingliang @ 2015-09-16 11:15 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/16 16:21, Thomas Gleixner wrote:
> On Wed, 16 Sep 2015, Yang Yingliang wrote:
>> arch/arm/Kconfig | 1 +
>> arch/arm/include/asm/irq.h | 1 -
>> arch/arm/kernel/irq.c | 62 -----------------------------------------
>> arch/arm64/Kconfig | 1 +
>> arch/arm64/include/asm/irq.h | 1 -
>> arch/arm64/kernel/irq.c | 62 -----------------------------------------
>> include/linux/irq.h | 4 +++
>> kernel/irq/migration.c | 66 ++++++++++++++++++++++++++++++++++++++++++++
>
> This want's to be split into seperate patches:
>
> #1 Provide the core infrastructure
>
> #2 Switch ARM to use it
>
> #3 Switch ARM64 to use it
OK, thanks for suggestion !
I will change it next verison.
Thanks,
Yang
>
> Thanks,
>
> tglx
>
> .
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-09-16 11:18 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-16 3:58 [RFC PATCH v3 0/3] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
2015-09-16 3:58 ` [RFC PATCH v3 1/3] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION Yang Yingliang
2015-09-16 8:13 ` Thomas Gleixner
2015-09-16 11:07 ` Yang Yingliang
2015-09-16 3:58 ` [RFC PATCH v3 2/3] ia64: rename migrate_irqs() to avoid compiling error Yang Yingliang
2015-09-16 8:21 ` Thomas Gleixner
2015-09-16 11:13 ` Yang Yingliang
2015-09-16 3:58 ` [RFC PATCH v3 3/3] arm/arm64: fix a migrating irq bug when hotplug cpu Yang Yingliang
2015-09-16 8:21 ` Thomas Gleixner
2015-09-16 11:15 ` Yang Yingliang
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).