
This commit backports IRQ affinity commits from the mainline kernel tree to the StarlingX kernel. (Links to the patch series can be found at the end of this commit message.) The intent is to be able to let certain device drivers (such as i40e, iavf, ice, ixgbe and mlx5) use the global IRQ affinity setting specified by 'irqaffinity=' on the kernel command line. In summary, a number of device drivers use the irq_set_affinity_hint function to provide a hint to the userspace about the ideal affinity to use with an IRQ. However, this function also sets the IRQ affinity, which makes the IRQ use the hinted affinity rather than the global IRQ affinity provided by the irqaffinity= argument. This is problematic for StarlingX, as interrupts are, in general, expected to be affined according to irqaffinity=, which is adjusted by Puppet. The patch series deprecates the kernel function irq_set_affinity_hint, and provides two replacements: (1) irq_set_affinity_and_hint and (2) irq_update_affinity_hint. Replacement function (1) sets both the affinity hint and the actual affinity, whereas (2) only sets the affinity hint. The original function -- irq_set_affinity_hint -- remains as a wrapper around (1), likely for backwards compatibility. The remaining patches in the series modify a number of device drivers to use the replacement functions. Of these patches, only the patch for the ixgbe driver is kept, for two reasons: - This commit aims to fix the IRQ affinities for network device drivers only. - StarlingX has out-of-tree modules for most of the remaining network device drivers, and these will be modified with a separate commit. Note that the first patch in this commit is included as a dependency for the others: genirq-Export-affinity-setter-for-modules.patch Finally, we should note that older versions of StarlingX that used CentOS 7's v3.10-based kernel did not have this issue, because of a CentOS 7-specific patch in that kernel that allowed the irqaffinity= kernel command line argument to take precedence over the device driver-provided IRQ affinity hints. Testing: - An ISO image was successfully built using a monolithic build procedure. - The ISO image was installed and bootstrapped successfully with an All-in-One simplex system (physical server) in low-latency mode. This server has a management/OAM Ethernet controller managed by the ixgbe driver, whose operation was observed to not have been negatively affected. - On another physical All-in-One simplex system which had one non-management/non-OAM Ethernet controller handled by the ixgbe driver, the IRQ affinities were confirmed to be set correctly by the changes in this commit. This was achieved by modifying two init scripts (affine-platfrom.sh and affine-interrupts.sh) so that they do not manipulate IRQ affinities, and observing IRQ affinities for ixgbe's interfaces with and without this patch. Change-Id: Ibf47fd301a460638f3bb4c49865adc3b2429e06d Partial-Bug: 1958417 Link: https://lore.kernel.org/netdev/20210903152430.244937-1-nitesh@redhat.com/ Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=147cc5838c0f5c76e908b816e924ca378e0d4735 Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
147 lines
5.1 KiB
Diff
147 lines
5.1 KiB
Diff
From 65d6ca9e8f41d14239e3e7618126f65df9982f92 Mon Sep 17 00:00:00 2001
|
|
From: Thomas Gleixner <tglx@linutronix.de>
|
|
Date: Fri, 3 Sep 2021 11:24:17 -0400
|
|
Subject: [PATCH] genirq: Provide new interfaces for affinity hints
|
|
|
|
The discussion about removing the side effect of irq_set_affinity_hint() of
|
|
actually applying the cpumask (if not NULL) as affinity to the interrupt,
|
|
unearthed a few unpleasantries:
|
|
|
|
1) The modular perf drivers rely on the current behaviour for the very
|
|
wrong reasons.
|
|
|
|
2) While none of the other drivers prevents user space from changing
|
|
the affinity, a cursorily inspection shows that there are at least
|
|
expectations in some drivers.
|
|
|
|
#1 needs to be cleaned up anyway, so that's not a problem
|
|
|
|
#2 might result in subtle regressions especially when irqbalanced (which
|
|
nowadays ignores the affinity hint) is disabled.
|
|
|
|
Provide new interfaces:
|
|
|
|
irq_update_affinity_hint() - Only sets the affinity hint pointer
|
|
irq_set_affinity_and_hint() - Set the pointer and apply the affinity to
|
|
the interrupt
|
|
|
|
Make irq_set_affinity_hint() a wrapper around irq_apply_affinity_hint() and
|
|
document it to be phased out.
|
|
|
|
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
|
|
Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com>
|
|
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
|
|
Reviewed-by: Ming Lei <ming.lei@redhat.com>
|
|
Link: https://lore.kernel.org/r/20210501021832.743094-1-jesse.brandeburg@intel.com
|
|
Link: https://lore.kernel.org/r/20210903152430.244937-2-nitesh@redhat.com
|
|
(cherry picked from commit 65c7cdedeb3026fabcc967a7aae2f755ad4d0783)
|
|
[mvb: Adapt to v5.10 by resolving a minor merge conflict.]
|
|
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
|
|
---
|
|
include/linux/interrupt.h | 52 ++++++++++++++++++++++++++++++++++++++-
|
|
kernel/irq/manage.c | 8 +++---
|
|
2 files changed, 55 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
|
|
index 10319f8da486..c1520fa7e843 100644
|
|
--- a/include/linux/interrupt.h
|
|
+++ b/include/linux/interrupt.h
|
|
@@ -320,7 +320,45 @@ extern int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask);
|
|
extern int irq_can_set_affinity(unsigned int irq);
|
|
extern int irq_select_affinity(unsigned int irq);
|
|
|
|
-extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m);
|
|
+extern int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m,
|
|
+ bool setaffinity);
|
|
+
|
|
+/**
|
|
+ * irq_update_affinity_hint - Update the affinity hint
|
|
+ * @irq: Interrupt to update
|
|
+ * @m: cpumask pointer (NULL to clear the hint)
|
|
+ *
|
|
+ * Updates the affinity hint, but does not change the affinity of the interrupt.
|
|
+ */
|
|
+static inline int
|
|
+irq_update_affinity_hint(unsigned int irq, const struct cpumask *m)
|
|
+{
|
|
+ return __irq_apply_affinity_hint(irq, m, false);
|
|
+}
|
|
+
|
|
+/**
|
|
+ * irq_set_affinity_and_hint - Update the affinity hint and apply the provided
|
|
+ * cpumask to the interrupt
|
|
+ * @irq: Interrupt to update
|
|
+ * @m: cpumask pointer (NULL to clear the hint)
|
|
+ *
|
|
+ * Updates the affinity hint and if @m is not NULL it applies it as the
|
|
+ * affinity of that interrupt.
|
|
+ */
|
|
+static inline int
|
|
+irq_set_affinity_and_hint(unsigned int irq, const struct cpumask *m)
|
|
+{
|
|
+ return __irq_apply_affinity_hint(irq, m, true);
|
|
+}
|
|
+
|
|
+/*
|
|
+ * Deprecated. Use irq_update_affinity_hint() or irq_set_affinity_and_hint()
|
|
+ * instead.
|
|
+ */
|
|
+static inline int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
|
|
+{
|
|
+ return irq_set_affinity_and_hint(irq, m);
|
|
+}
|
|
|
|
extern int
|
|
irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify);
|
|
@@ -350,6 +388,18 @@ static inline int irq_can_set_affinity(unsigned int irq)
|
|
|
|
static inline int irq_select_affinity(unsigned int irq) { return 0; }
|
|
|
|
+static inline int irq_update_affinity_hint(unsigned int irq,
|
|
+ const struct cpumask *m)
|
|
+{
|
|
+ return -EINVAL;
|
|
+}
|
|
+
|
|
+static inline int irq_set_affinity_and_hint(unsigned int irq,
|
|
+ const struct cpumask *m)
|
|
+{
|
|
+ return -EINVAL;
|
|
+}
|
|
+
|
|
static inline int irq_set_affinity_hint(unsigned int irq,
|
|
const struct cpumask *m)
|
|
{
|
|
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
|
|
index d7974de65659..836e7111b584 100644
|
|
--- a/kernel/irq/manage.c
|
|
+++ b/kernel/irq/manage.c
|
|
@@ -417,7 +417,8 @@ int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask)
|
|
}
|
|
EXPORT_SYMBOL_GPL(irq_force_affinity);
|
|
|
|
-int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
|
|
+int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m,
|
|
+ bool setaffinity)
|
|
{
|
|
unsigned long flags;
|
|
struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL);
|
|
@@ -426,12 +427,11 @@ int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
|
|
return -EINVAL;
|
|
desc->affinity_hint = m;
|
|
irq_put_desc_unlock(desc, flags);
|
|
- /* set the initial affinity to prevent every interrupt being on CPU0 */
|
|
- if (m)
|
|
+ if (m && setaffinity)
|
|
__irq_set_affinity(irq, m, false);
|
|
return 0;
|
|
}
|
|
-EXPORT_SYMBOL_GPL(irq_set_affinity_hint);
|
|
+EXPORT_SYMBOL_GPL(__irq_apply_affinity_hint);
|
|
|
|
static void irq_affinity_notify(struct work_struct *work)
|
|
{
|
|
--
|
|
2.29.2
|
|
|