kernel/kernel-std/debian/patches/0018-genirq-Provide-new-interfaces-for-affinity-hints.patch
Li Zhou 998d337c2b Debian: porting kernel commits from centos
To keep kernel debian stx aligned with centos stx, porting below commits
from centos stx to debian stx:
(1)patches related
   ef3c9a4 kernel: Add auxiliary bus support
   19ca0df kernel: Backport IRQ affinity patches
   a10b746 workqueue affinity: Remove unused variable
   8fde1a8 kthread_cpus: Avoid large stack allocation
   bb6ec66 scsi: Make the disk detection order more consistent
   bf940a8 rcu: Avoid RCU-related unexpected reboot
   cfe452a workqueue: Affine rescuer threads and unbound wqs
(2)config related
   6fe8d60 kernel: Disable NVMe multi-path kconfig option
   c9cdb90 Fixup recent kconfig cleanup
   8551799 Resolve v5.10 kernel configuration file differences
(3)kernel-modules related
   7ded004 kernel-modules: IRQ affinity hint fix-ups

Please pay attention to:
[ef3c9a4 kernel: Add auxiliary bus support]
which is not only related with kernel patches but also related with
kernel-modules.
It removes the auxiliary.ko from the oot ice package because auxiliary
bus device driver is built into kernel. But the detecting of builtin
auxiliary driver in intel-iavf/intel-ice oot driver will fail because
debian has 2 linux header packages. So extra patches are added for
intel-iavf and intel-ice to pass linux common header to check_aux_bus
to make builtin auxiliary driver detected. At the same time the patch
[check_aux_bus: Look for kernel headers in the right location]
for the oot drivers is removed because it isn't needed any more if
the right header path is passed.

Test Plan:
 - PASS: Build kernel-std/kernel-rt.
 - PASS: Build the 7 oot kernel modules for kernel-std/kernel-rt.
 - PASS: Build the iso for kernel-std and modules and boot up on qemu.
 - PASS: Build the test iso for kernel-rt and modules and boot up
         on qemu.

Story: 2009221
Task: 44989
Signed-off-by: Li Zhou <li.zhou@windriver.com>
Change-Id: Ic7cddc068eab1516800e90bfe431d042274f86d3
2022-04-14 21:33:05 -04:00

147 lines
5.1 KiB
Diff

From d4b260fea6b5d7f0da84236f97b385312ab2e0ac 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 087a1cfad35c..72350bdee846 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 eeedb6224e2f..63e7de3683d2 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