diff --git a/kernel-rt/centos/kernel-rt.spec b/kernel-rt/centos/kernel-rt.spec index 5cd83728..a2231d09 100644 --- a/kernel-rt/centos/kernel-rt.spec +++ b/kernel-rt/centos/kernel-rt.spec @@ -792,6 +792,9 @@ Patch12: 0013-rcu-Mark-accesses-to-rcu_state.n_force_qs.patch Patch13: 0014-rcu-Tighten-rcu_advance_cbs_nowake-checks.patch Patch14: 0015-Revert-scsi-sd-Inline-sd_probe_part2.patch Patch15: 0016-Revert-commit-f049cf1a7b.patch +Patch16: 0017-genirq-Export-affinity-setter-for-modules.patch +Patch17: 0018-genirq-Provide-new-interfaces-for-affinity-hints.patch +Patch18: 0019-ixgbe-Use-irq_update_affinity_hint.patch # END OF PATCH DEFINITIONS %endif diff --git a/kernel-rt/centos/patches/0017-genirq-Export-affinity-setter-for-modules.patch b/kernel-rt/centos/patches/0017-genirq-Export-affinity-setter-for-modules.patch new file mode 100644 index 00000000..8a8bd275 --- /dev/null +++ b/kernel-rt/centos/patches/0017-genirq-Export-affinity-setter-for-modules.patch @@ -0,0 +1,124 @@ +From f53c29e1392a5f67bc937227417bd786e7594e22 Mon Sep 17 00:00:00 2001 +From: Thomas Gleixner +Date: Tue, 18 May 2021 11:17:26 +0200 +Subject: [PATCH] genirq: Export affinity setter for modules + +Perf modules abuse irq_set_affinity_hint() to set the affinity of system +PMU interrupts just because irq_set_affinity() was not exported. + +The fact that irq_set_affinity_hint() actually sets the affinity is a +non-documented side effect and the name is clearly saying it's a hint. + +To clean this up, export the real affinity setter. + +Signed-off-by: Thomas Gleixner +Acked-by: Mark Rutland +Link: https://lore.kernel.org/r/20210518093117.968251441@linutronix.de +(cherry picked from commit 4d80d6ca5d77fde9880da8466e5b64f250e5bf82) +[mvb: Adjust context for a function that does not exist in v5.10.] +Signed-off-by: M. Vefa Bicakci +--- + include/linux/interrupt.h | 35 ++--------------------------------- + kernel/irq/manage.c | 33 ++++++++++++++++++++++++++++++++- + 2 files changed, 34 insertions(+), 34 deletions(-) + +diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h +index 7545a2f18560..10319f8da486 100644 +--- a/include/linux/interrupt.h ++++ b/include/linux/interrupt.h +@@ -314,39 +314,8 @@ struct irq_affinity_desc { + + extern cpumask_var_t irq_default_affinity; + +-/* Internal implementation. Use the helpers below */ +-extern int __irq_set_affinity(unsigned int irq, const struct cpumask *cpumask, +- bool force); +- +-/** +- * irq_set_affinity - Set the irq affinity of a given irq +- * @irq: Interrupt to set affinity +- * @cpumask: cpumask +- * +- * Fails if cpumask does not contain an online CPU +- */ +-static inline int +-irq_set_affinity(unsigned int irq, const struct cpumask *cpumask) +-{ +- return __irq_set_affinity(irq, cpumask, false); +-} +- +-/** +- * irq_force_affinity - Force the irq affinity of a given irq +- * @irq: Interrupt to set affinity +- * @cpumask: cpumask +- * +- * Same as irq_set_affinity, but without checking the mask against +- * online cpus. +- * +- * Solely for low level cpu hotplug code, where we need to make per +- * cpu interrupts affine before the cpu becomes online. +- */ +-static inline int +-irq_force_affinity(unsigned int irq, const struct cpumask *cpumask) +-{ +- return __irq_set_affinity(irq, cpumask, true); +-} ++extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask); ++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); +diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c +index 84a120d3abef..d7974de65659 100644 +--- a/kernel/irq/manage.c ++++ b/kernel/irq/manage.c +@@ -371,7 +371,8 @@ int irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask, + return ret; + } + +-int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, bool force) ++static int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, ++ bool force) + { + struct irq_desc *desc = irq_to_desc(irq); + unsigned long flags; +@@ -386,6 +387,36 @@ int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, bool force) + return ret; + } + ++/** ++ * irq_set_affinity - Set the irq affinity of a given irq ++ * @irq: Interrupt to set affinity ++ * @cpumask: cpumask ++ * ++ * Fails if cpumask does not contain an online CPU ++ */ ++int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask) ++{ ++ return __irq_set_affinity(irq, cpumask, false); ++} ++EXPORT_SYMBOL_GPL(irq_set_affinity); ++ ++/** ++ * irq_force_affinity - Force the irq affinity of a given irq ++ * @irq: Interrupt to set affinity ++ * @cpumask: cpumask ++ * ++ * Same as irq_set_affinity, but without checking the mask against ++ * online cpus. ++ * ++ * Solely for low level cpu hotplug code, where we need to make per ++ * cpu interrupts affine before the cpu becomes online. ++ */ ++int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask) ++{ ++ return __irq_set_affinity(irq, cpumask, true); ++} ++EXPORT_SYMBOL_GPL(irq_force_affinity); ++ + int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m) + { + unsigned long flags; +-- +2.29.2 + diff --git a/kernel-rt/centos/patches/0018-genirq-Provide-new-interfaces-for-affinity-hints.patch b/kernel-rt/centos/patches/0018-genirq-Provide-new-interfaces-for-affinity-hints.patch new file mode 100644 index 00000000..cf3337f1 --- /dev/null +++ b/kernel-rt/centos/patches/0018-genirq-Provide-new-interfaces-for-affinity-hints.patch @@ -0,0 +1,146 @@ +From 65d6ca9e8f41d14239e3e7618126f65df9982f92 Mon Sep 17 00:00:00 2001 +From: Thomas Gleixner +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 +Signed-off-by: Nitesh Narayan Lal +Signed-off-by: Thomas Gleixner +Reviewed-by: Ming Lei +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 +--- + 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 + diff --git a/kernel-rt/centos/patches/0019-ixgbe-Use-irq_update_affinity_hint.patch b/kernel-rt/centos/patches/0019-ixgbe-Use-irq_update_affinity_hint.patch new file mode 100644 index 00000000..0cfd17cd --- /dev/null +++ b/kernel-rt/centos/patches/0019-ixgbe-Use-irq_update_affinity_hint.patch @@ -0,0 +1,64 @@ +From ec3682a03a0be93ec7e6c8706ab89846cfad4232 Mon Sep 17 00:00:00 2001 +From: Nitesh Narayan Lal +Date: Fri, 3 Sep 2021 11:24:25 -0400 +Subject: [PATCH] ixgbe: Use irq_update_affinity_hint() + +The driver uses irq_set_affinity_hint() to update the affinity_hint mask +that is consumed by the userspace to distribute the interrupts. However, +under the hood irq_set_affinity_hint() also applies the provided cpumask +(if not NULL) as the affinity for the given interrupt which is an +undocumented side effect. + +To remove this side effect irq_set_affinity_hint() has been marked +as deprecated and new interfaces have been introduced. Hence, replace the +irq_set_affinity_hint() with the new interface irq_update_affinity_hint() +that only updates the affinity_hint pointer. + +Signed-off-by: Nitesh Narayan Lal +Signed-off-by: Thomas Gleixner +Acked-by: Jesse Brandeburg +Link: https://lore.kernel.org/r/20210903152430.244937-10-nitesh@redhat.com +(cherry picked from commit cc493264c01d055742a34cfbaecaffb258dcc58c) +Signed-off-by: M. Vefa Bicakci +--- + drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +index ffe322136c58..fe10776d8479 100644 +--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c ++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +@@ -3250,8 +3250,8 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter) + /* If Flow Director is enabled, set interrupt affinity */ + if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { + /* assign the mask for this irq */ +- irq_set_affinity_hint(entry->vector, +- &q_vector->affinity_mask); ++ irq_update_affinity_hint(entry->vector, ++ &q_vector->affinity_mask); + } + } + +@@ -3267,8 +3267,8 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter) + free_queue_irqs: + while (vector) { + vector--; +- irq_set_affinity_hint(adapter->msix_entries[vector].vector, +- NULL); ++ irq_update_affinity_hint(adapter->msix_entries[vector].vector, ++ NULL); + free_irq(adapter->msix_entries[vector].vector, + adapter->q_vector[vector]); + } +@@ -3401,7 +3401,7 @@ static void ixgbe_free_irq(struct ixgbe_adapter *adapter) + continue; + + /* clear the affinity_mask in the IRQ descriptor */ +- irq_set_affinity_hint(entry->vector, NULL); ++ irq_update_affinity_hint(entry->vector, NULL); + + free_irq(entry->vector, q_vector); + } +-- +2.29.2 + diff --git a/kernel-std/centos/kernel.spec b/kernel-std/centos/kernel.spec index 30fdbb45..b0412ec5 100644 --- a/kernel-std/centos/kernel.spec +++ b/kernel-std/centos/kernel.spec @@ -825,6 +825,9 @@ Patch12: 0013-rcu-Mark-accesses-to-rcu_state.n_force_qs.patch Patch13: 0014-rcu-Tighten-rcu_advance_cbs_nowake-checks.patch Patch14: 0015-Revert-scsi-sd-Inline-sd_probe_part2.patch Patch15: 0016-Revert-commit-f049cf1a7b.patch +Patch16: 0017-genirq-Export-affinity-setter-for-modules.patch +Patch17: 0018-genirq-Provide-new-interfaces-for-affinity-hints.patch +Patch18: 0019-ixgbe-Use-irq_update_affinity_hint.patch # END OF PATCH DEFINITIONS %endif diff --git a/kernel-std/centos/patches/0017-genirq-Export-affinity-setter-for-modules.patch b/kernel-std/centos/patches/0017-genirq-Export-affinity-setter-for-modules.patch new file mode 100644 index 00000000..a56cd82c --- /dev/null +++ b/kernel-std/centos/patches/0017-genirq-Export-affinity-setter-for-modules.patch @@ -0,0 +1,124 @@ +From 7c2dc6277376104f8cfe7f8d07c77f6d7155fb73 Mon Sep 17 00:00:00 2001 +From: Thomas Gleixner +Date: Tue, 18 May 2021 11:17:26 +0200 +Subject: [PATCH] genirq: Export affinity setter for modules + +Perf modules abuse irq_set_affinity_hint() to set the affinity of system +PMU interrupts just because irq_set_affinity() was not exported. + +The fact that irq_set_affinity_hint() actually sets the affinity is a +non-documented side effect and the name is clearly saying it's a hint. + +To clean this up, export the real affinity setter. + +Signed-off-by: Thomas Gleixner +Acked-by: Mark Rutland +Link: https://lore.kernel.org/r/20210518093117.968251441@linutronix.de +(cherry picked from commit 4d80d6ca5d77fde9880da8466e5b64f250e5bf82) +[mvb: Adjust context for a function that does not exist in v5.10.] +Signed-off-by: M. Vefa Bicakci +--- + include/linux/interrupt.h | 35 ++--------------------------------- + kernel/irq/manage.c | 33 ++++++++++++++++++++++++++++++++- + 2 files changed, 34 insertions(+), 34 deletions(-) + +diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h +index ee8299eb1f52..087a1cfad35c 100644 +--- a/include/linux/interrupt.h ++++ b/include/linux/interrupt.h +@@ -314,39 +314,8 @@ struct irq_affinity_desc { + + extern cpumask_var_t irq_default_affinity; + +-/* Internal implementation. Use the helpers below */ +-extern int __irq_set_affinity(unsigned int irq, const struct cpumask *cpumask, +- bool force); +- +-/** +- * irq_set_affinity - Set the irq affinity of a given irq +- * @irq: Interrupt to set affinity +- * @cpumask: cpumask +- * +- * Fails if cpumask does not contain an online CPU +- */ +-static inline int +-irq_set_affinity(unsigned int irq, const struct cpumask *cpumask) +-{ +- return __irq_set_affinity(irq, cpumask, false); +-} +- +-/** +- * irq_force_affinity - Force the irq affinity of a given irq +- * @irq: Interrupt to set affinity +- * @cpumask: cpumask +- * +- * Same as irq_set_affinity, but without checking the mask against +- * online cpus. +- * +- * Solely for low level cpu hotplug code, where we need to make per +- * cpu interrupts affine before the cpu becomes online. +- */ +-static inline int +-irq_force_affinity(unsigned int irq, const struct cpumask *cpumask) +-{ +- return __irq_set_affinity(irq, cpumask, true); +-} ++extern int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask); ++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); +diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c +index 420b5ce0bf89..eeedb6224e2f 100644 +--- a/kernel/irq/manage.c ++++ b/kernel/irq/manage.c +@@ -371,7 +371,8 @@ int irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask, + return ret; + } + +-int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, bool force) ++static int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, ++ bool force) + { + struct irq_desc *desc = irq_to_desc(irq); + unsigned long flags; +@@ -386,6 +387,36 @@ int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, bool force) + return ret; + } + ++/** ++ * irq_set_affinity - Set the irq affinity of a given irq ++ * @irq: Interrupt to set affinity ++ * @cpumask: cpumask ++ * ++ * Fails if cpumask does not contain an online CPU ++ */ ++int irq_set_affinity(unsigned int irq, const struct cpumask *cpumask) ++{ ++ return __irq_set_affinity(irq, cpumask, false); ++} ++EXPORT_SYMBOL_GPL(irq_set_affinity); ++ ++/** ++ * irq_force_affinity - Force the irq affinity of a given irq ++ * @irq: Interrupt to set affinity ++ * @cpumask: cpumask ++ * ++ * Same as irq_set_affinity, but without checking the mask against ++ * online cpus. ++ * ++ * Solely for low level cpu hotplug code, where we need to make per ++ * cpu interrupts affine before the cpu becomes online. ++ */ ++int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask) ++{ ++ return __irq_set_affinity(irq, cpumask, true); ++} ++EXPORT_SYMBOL_GPL(irq_force_affinity); ++ + int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m) + { + unsigned long flags; +-- +2.29.2 + diff --git a/kernel-std/centos/patches/0018-genirq-Provide-new-interfaces-for-affinity-hints.patch b/kernel-std/centos/patches/0018-genirq-Provide-new-interfaces-for-affinity-hints.patch new file mode 100644 index 00000000..ac466b78 --- /dev/null +++ b/kernel-std/centos/patches/0018-genirq-Provide-new-interfaces-for-affinity-hints.patch @@ -0,0 +1,146 @@ +From d4b260fea6b5d7f0da84236f97b385312ab2e0ac Mon Sep 17 00:00:00 2001 +From: Thomas Gleixner +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 +Signed-off-by: Nitesh Narayan Lal +Signed-off-by: Thomas Gleixner +Reviewed-by: Ming Lei +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 +--- + 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 + diff --git a/kernel-std/centos/patches/0019-ixgbe-Use-irq_update_affinity_hint.patch b/kernel-std/centos/patches/0019-ixgbe-Use-irq_update_affinity_hint.patch new file mode 100644 index 00000000..03afb03b --- /dev/null +++ b/kernel-std/centos/patches/0019-ixgbe-Use-irq_update_affinity_hint.patch @@ -0,0 +1,64 @@ +From 07298341feaa2c35fdd225735b4ee5299efb112f Mon Sep 17 00:00:00 2001 +From: Nitesh Narayan Lal +Date: Fri, 3 Sep 2021 11:24:25 -0400 +Subject: [PATCH] ixgbe: Use irq_update_affinity_hint() + +The driver uses irq_set_affinity_hint() to update the affinity_hint mask +that is consumed by the userspace to distribute the interrupts. However, +under the hood irq_set_affinity_hint() also applies the provided cpumask +(if not NULL) as the affinity for the given interrupt which is an +undocumented side effect. + +To remove this side effect irq_set_affinity_hint() has been marked +as deprecated and new interfaces have been introduced. Hence, replace the +irq_set_affinity_hint() with the new interface irq_update_affinity_hint() +that only updates the affinity_hint pointer. + +Signed-off-by: Nitesh Narayan Lal +Signed-off-by: Thomas Gleixner +Acked-by: Jesse Brandeburg +Link: https://lore.kernel.org/r/20210903152430.244937-10-nitesh@redhat.com +(cherry picked from commit cc493264c01d055742a34cfbaecaffb258dcc58c) +Signed-off-by: M. Vefa Bicakci +--- + drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +index ffe322136c58..fe10776d8479 100644 +--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c ++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +@@ -3250,8 +3250,8 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter) + /* If Flow Director is enabled, set interrupt affinity */ + if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { + /* assign the mask for this irq */ +- irq_set_affinity_hint(entry->vector, +- &q_vector->affinity_mask); ++ irq_update_affinity_hint(entry->vector, ++ &q_vector->affinity_mask); + } + } + +@@ -3267,8 +3267,8 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter) + free_queue_irqs: + while (vector) { + vector--; +- irq_set_affinity_hint(adapter->msix_entries[vector].vector, +- NULL); ++ irq_update_affinity_hint(adapter->msix_entries[vector].vector, ++ NULL); + free_irq(adapter->msix_entries[vector].vector, + adapter->q_vector[vector]); + } +@@ -3401,7 +3401,7 @@ static void ixgbe_free_irq(struct ixgbe_adapter *adapter) + continue; + + /* clear the affinity_mask in the IRQ descriptor */ +- irq_set_affinity_hint(entry->vector, NULL); ++ irq_update_affinity_hint(entry->vector, NULL); + + free_irq(entry->vector, q_vector); + } +-- +2.29.2 +