Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1231973 > unrolled thread
| Started by | Yang Yingliang <yangyingliang@huawei.com> |
|---|---|
| First post | 2015-09-24 11:40 +0200 |
| Last post | 2015-10-01 16:50 +0200 |
| Articles | 4 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[RFC PATCH v6 1/3] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION and kernel/irq/cpuhotplug.c Yang Yingliang <yangyingliang@huawei.com> - 2015-09-24 11:40 +0200
[tip:irq/core] genirq: Introduce generic irq migration for cpu hotunplug tip-bot for Yang Yingliang <tipbot@zytor.com> - 2015-10-01 16:20 +0200
Re: [tip:irq/core] genirq: Introduce generic irq migration for cpu hotunplug Thomas Gleixner <tglx@linutronix.de> - 2015-10-01 16:30 +0200
Re: [tip:irq/core] genirq: Introduce generic irq migration for cpu hotunplug Catalin Marinas <catalin.marinas@arm.com> - 2015-10-01 16:50 +0200
| From | Yang Yingliang <yangyingliang@huawei.com> |
|---|---|
| Date | 2015-09-24 11:40 +0200 |
| Subject | [RFC PATCH v6 1/3] genirq: introduce CONFIG_GENERIC_IRQ_MIGRATION and kernel/irq/cpuhotplug.c |
| Message-ID | <qcbaq-7wh-7@gated-at.bofh.it> |
Add migrating interrupts code to a new file kernel/irq/cpuhotplug.c and
make it depends on CONFIG_GENERIC_IRQ_MIGRATION. So we can use it to migrate
interrupts, before 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/Kconfig | 4 +++
kernel/irq/Makefile | 1 +
kernel/irq/cpuhotplug.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 75 insertions(+)
create mode 100644 kernel/irq/cpuhotplug.c
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 11bf092..45cc729 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -452,6 +452,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/Kconfig b/kernel/irq/Kconfig
index 9a76e3b..3b48dab 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 migrating off cpu before the cpu is offline.
+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..2fc9cbd 100644
--- a/kernel/irq/Makefile
+++ b/kernel/irq/Makefile
@@ -5,5 +5,6 @@ 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) += cpuhotplug.o
obj-$(CONFIG_PM_SLEEP) += pm.o
obj-$(CONFIG_GENERIC_MSI_IRQ) += msi.o
diff --git a/kernel/irq/cpuhotplug.c b/kernel/irq/cpuhotplug.c
new file mode 100644
index 0000000..8f2e9c0
--- /dev/null
+++ b/kernel/irq/cpuhotplug.c
@@ -0,0 +1,68 @@
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/ratelimit.h>
+
+#include "internals.h"
+
+static bool migrate_one_irq(struct irq_desc *desc)
+{
+ struct irq_data *d = irq_desc_get_irq_data(desc);
+ const struct cpumask *affinity = d->common->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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | tip-bot for Yang Yingliang <tipbot@zytor.com> |
|---|---|
| Date | 2015-10-01 16:20 +0200 |
| Subject | [tip:irq/core] genirq: Introduce generic irq migration for cpu hotunplug |
| Message-ID | <qeMSe-6WP-19@gated-at.bofh.it> |
| In reply to | #1231973 |
Commit-ID: f1e0bb0ad473a32d1b7e6d285ae9f7e47710bb5e
Gitweb: http://git.kernel.org/tip/f1e0bb0ad473a32d1b7e6d285ae9f7e47710bb5e
Author: Yang Yingliang <yangyingliang@huawei.com>
AuthorDate: Thu, 24 Sep 2015 17:32:13 +0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 1 Oct 2015 14:51:15 +0200
genirq: Introduce generic irq migration for cpu hotunplug
ARM and ARM64 have almost identical code for migrating interrupts on
cpu hotunplug. Provide a generic version which can be used by both.
The new code addresses a shortcoming in the ARM[64] variants which
fails to update the affinity change in some cases. The solution for
this is to use the core function irq_do_set_affinity() instead of open
coding it.
[ tglx: Added copyright notice and license boilerplate. Rewrote
subject and changelog. ]
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Hanjun Guo <hanjun.guo@linaro.org>
Cc: <linux-arm-kernel@lists.infradead.org>
Link: http://lkml.kernel.org/r/1443087135-17044-2-git-send-email-yangyingliang@huawei.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/irq.h | 2 ++
kernel/irq/Kconfig | 4 +++
kernel/irq/Makefile | 1 +
kernel/irq/cpuhotplug.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 89 insertions(+)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 11bf092..45cc729 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -452,6 +452,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/Kconfig b/kernel/irq/Kconfig
index 9a76e3b..3b48dab 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 migrating off cpu before the cpu is offline.
+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..2fc9cbd 100644
--- a/kernel/irq/Makefile
+++ b/kernel/irq/Makefile
@@ -5,5 +5,6 @@ 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) += cpuhotplug.o
obj-$(CONFIG_PM_SLEEP) += pm.o
obj-$(CONFIG_GENERIC_MSI_IRQ) += msi.o
diff --git a/kernel/irq/cpuhotplug.c b/kernel/irq/cpuhotplug.c
new file mode 100644
index 0000000..80f4f4e
--- /dev/null
+++ b/kernel/irq/cpuhotplug.c
@@ -0,0 +1,82 @@
+/*
+ * Generic cpu hotunplug interrupt migration code copied from the
+ * arch/arm implementation
+ *
+ * Copyright (C) Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/interrupt.h>
+#include <linux/ratelimit.h>
+#include <linux/irq.h>
+
+#include "internals.h"
+
+static bool migrate_one_irq(struct irq_desc *desc)
+{
+ struct irq_data *d = irq_desc_get_irq_data(desc);
+ const struct cpumask *affinity = d->common->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;
+}
+
+/**
+ * irq_migrate_all_off_this_cpu - Migrate irqs away from offline cpu
+ *
+ * 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);
+}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2015-10-01 16:30 +0200 |
| Subject | Re: [tip:irq/core] genirq: Introduce generic irq migration for cpu hotunplug |
| Message-ID | <qeN1U-795-5@gated-at.bofh.it> |
| In reply to | #1237446 |
On Thu, 1 Oct 2015, tip-bot for Yang Yingliang wrote: > Commit-ID: f1e0bb0ad473a32d1b7e6d285ae9f7e47710bb5e > Gitweb: http://git.kernel.org/tip/f1e0bb0ad473a32d1b7e6d285ae9f7e47710bb5e > Author: Yang Yingliang <yangyingliang@huawei.com> > AuthorDate: Thu, 24 Sep 2015 17:32:13 +0800 > Committer: Thomas Gleixner <tglx@linutronix.de> > CommitDate: Thu, 1 Oct 2015 14:51:15 +0200 > > genirq: Introduce generic irq migration for cpu hotunplug > > ARM and ARM64 have almost identical code for migrating interrupts on > cpu hotunplug. Provide a generic version which can be used by both. > > The new code addresses a shortcoming in the ARM[64] variants which > fails to update the affinity change in some cases. The solution for > this is to use the core function irq_do_set_affinity() instead of open > coding it. > > [ tglx: Added copyright notice and license boilerplate. Rewrote > subject and changelog. ] > > Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> > Acked-by: Russell King - ARM Linux <linux@arm.linux.org.uk> > Cc: Jiang Liu <jiang.liu@linux.intel.com> > Cc: Marc Zyngier <marc.zyngier@arm.com> > Cc: Mark Rutland <mark.rutland@arm.com> > Cc: Will Deacon <will.deacon@arm.com> > Cc: Hanjun Guo <hanjun.guo@linaro.org> > Cc: <linux-arm-kernel@lists.infradead.org> > Link: http://lkml.kernel.org/r/1443087135-17044-2-git-send-email-yangyingliang@huawei.com > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Russell, Will, I applied that to a seperate branch git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/for-arm You can pull that into arm[64] so you can apply the architecture specific part. Thanks, tglx -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Catalin Marinas <catalin.marinas@arm.com> |
|---|---|
| Date | 2015-10-01 16:50 +0200 |
| Subject | Re: [tip:irq/core] genirq: Introduce generic irq migration for cpu hotunplug |
| Message-ID | <qeNlg-7wZ-23@gated-at.bofh.it> |
| In reply to | #1237450 |
On Thu, Oct 01, 2015 at 04:24:24PM +0200, Thomas Gleixner wrote: > On Thu, 1 Oct 2015, tip-bot for Yang Yingliang wrote: > > > Commit-ID: f1e0bb0ad473a32d1b7e6d285ae9f7e47710bb5e > > Gitweb: http://git.kernel.org/tip/f1e0bb0ad473a32d1b7e6d285ae9f7e47710bb5e > > Author: Yang Yingliang <yangyingliang@huawei.com> > > AuthorDate: Thu, 24 Sep 2015 17:32:13 +0800 > > Committer: Thomas Gleixner <tglx@linutronix.de> > > CommitDate: Thu, 1 Oct 2015 14:51:15 +0200 > > > > genirq: Introduce generic irq migration for cpu hotunplug > > > > ARM and ARM64 have almost identical code for migrating interrupts on > > cpu hotunplug. Provide a generic version which can be used by both. > > > > The new code addresses a shortcoming in the ARM[64] variants which > > fails to update the affinity change in some cases. The solution for > > this is to use the core function irq_do_set_affinity() instead of open > > coding it. > > > > [ tglx: Added copyright notice and license boilerplate. Rewrote > > subject and changelog. ] > > > > Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> > > Acked-by: Russell King - ARM Linux <linux@arm.linux.org.uk> > > Cc: Jiang Liu <jiang.liu@linux.intel.com> > > Cc: Marc Zyngier <marc.zyngier@arm.com> > > Cc: Mark Rutland <mark.rutland@arm.com> > > Cc: Will Deacon <will.deacon@arm.com> > > Cc: Hanjun Guo <hanjun.guo@linaro.org> > > Cc: <linux-arm-kernel@lists.infradead.org> > > Link: http://lkml.kernel.org/r/1443087135-17044-2-git-send-email-yangyingliang@huawei.com > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> > > Russell, Will, > > I applied that to a seperate branch > > git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/for-arm > > You can pull that into arm[64] so you can apply the architecture > specific part. Thanks. I'll queue the corresponding arm64 patch for 4.4. -- Catalin -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web