All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH tip:irq/core v1] genirq: remove auto-set of the mask when setting the hint
@ 2021-05-01  2:18 ` Jesse Brandeburg
  0 siblings, 0 replies; 71+ messages in thread
From: Jesse Brandeburg @ 2021-05-01  2:18 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, linux-kernel, intel-wired-lan, jbrandeb, frederic,
	juri.lelli, Marcelo Tosatti, abelits, Robin Murphy, linux-api,
	bhelgaas, linux-pci, rostedt, peterz, davem, akpm, sfr, stephen,
	rppt, jinyuqi, zhangshaokun, netdev, chris.friesen,
	Jesse Brandeburg, Nitesh Lal

It was pointed out by Nitesh that the original work I did in 2014
to automatically set the interrupt affinity when requesting a
mask is no longer necessary. The kernel has moved on and no
longer has the original problem, BUT the original patch
introduced a subtle bug when booting a system with reserved or
excluded CPUs. Drivers calling this function with a mask value
that included a CPU that was currently or in the future
unavailable would generally not update the hint.

I'm sure there are a million ways to solve this, but the simplest
one is to just remove a little code that tries to force the
affinity, as Nitesh has shown it fixes the bug and doesn't seem
to introduce immediate side effects.

While I'm here, introduce a kernel-doc for the hint function.

Ref: https://lore.kernel.org/lkml/CAFki+L=_dd+JgAR12_eBPX0kZO2_6=1dGdgkwHE=u=K6chMeLQ@mail.gmail.com/
Cc: netdev@vger.kernel.org
Fixes: 4fe7ffb7e17c ("genirq: Fix null pointer reference in irq_set_affinity_hint()")
Fixes: e2e64a932556 ("genirq: Set initial affinity in irq_set_affinity_hint()")
Reported-by: Nitesh Lal <nilal@redhat.com>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
---

!!! NOTE: Compile tested only, would appreciate feedback

---
 kernel/irq/manage.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index e976c4927b25..a31df64662d5 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -456,6 +456,16 @@ int __irq_set_affinity(unsigned int irq, const struct cpumask *mask, bool force)
 	return ret;
 }
 
+/**
+ * 	irq_set_affinity_hint - set the hint for an irq
+ *	@irq:	Interrupt for which to set the hint
+ *	@m:	Mask to indicate which CPUs to suggest for the interrupt, use
+ *		NULL here to indicate to clear the value.
+ *
+ *	Use this function to recommend which CPU should handle the
+ *	interrupt to any userspace that uses /proc/irq/nn/smp_affinity_hint
+ *	in order to align interrupts. Pass NULL as the mask to clear the hint.
+ */
 int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
 {
 	unsigned long flags;
@@ -465,9 +475,6 @@ 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)
-		__irq_set_affinity(irq, m, false);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(irq_set_affinity_hint);

base-commit: 765822e1569a37aab5e69736c52d4ad4a289eba6
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 71+ messages in thread

end of thread, other threads:[~2021-12-10 19:54 UTC | newest]

Thread overview: 71+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-01  2:18 [PATCH tip:irq/core v1] genirq: remove auto-set of the mask when setting the hint Jesse Brandeburg
2021-05-01  2:18 ` [Intel-wired-lan] " Jesse Brandeburg
2021-05-04 12:15 ` Robin Murphy
2021-05-04 12:15   ` [Intel-wired-lan] " Robin Murphy
2021-05-04 14:29   ` Nitesh Lal
2021-05-04 14:29     ` [Intel-wired-lan] " Nitesh Lal
2021-05-04 16:23   ` Jesse Brandeburg
2021-05-04 16:23     ` [Intel-wired-lan] " Jesse Brandeburg
2021-05-17 16:57     ` Nitesh Lal
2021-05-17 16:57       ` [Intel-wired-lan] " Nitesh Lal
2021-05-17 17:26       ` Robin Murphy
2021-05-17 17:26         ` [Intel-wired-lan] " Robin Murphy
2021-05-17 18:08         ` Thomas Gleixner
2021-05-17 18:08           ` [Intel-wired-lan] " Thomas Gleixner
2021-05-17 18:50           ` Robin Murphy
2021-05-17 18:50             ` [Intel-wired-lan] " Robin Murphy
2021-05-17 19:08             ` Thomas Gleixner
2021-05-17 19:08               ` [Intel-wired-lan] " Thomas Gleixner
2021-05-17 19:43               ` Thomas Gleixner
2021-05-17 19:43                 ` [Intel-wired-lan] " Thomas Gleixner
2021-05-17 20:18               ` Thomas Gleixner
2021-05-17 20:18                 ` [Intel-wired-lan] " Thomas Gleixner
2021-05-17 18:21         ` Nitesh Lal
2021-05-17 18:21           ` [Intel-wired-lan] " Nitesh Lal
2021-05-17 19:47           ` Thomas Gleixner
2021-05-17 19:47             ` [Intel-wired-lan] " Thomas Gleixner
2021-05-17 21:13             ` Nitesh Lal
2021-05-17 21:13               ` [Intel-wired-lan] " Nitesh Lal
2021-05-17 20:48     ` Thomas Gleixner
2021-05-17 20:48       ` [Intel-wired-lan] " Thomas Gleixner
2021-05-17 22:44       ` Nitesh Lal
2021-05-17 22:44         ` [Intel-wired-lan] " Nitesh Lal
2021-05-18  0:03         ` Thomas Gleixner
2021-05-18  0:03           ` [Intel-wired-lan] " Thomas Gleixner
2021-05-18  0:23           ` Nitesh Lal
2021-05-18  0:23             ` [Intel-wired-lan] " Nitesh Lal
2021-05-20 21:57             ` Nitesh Lal
2021-05-20 21:57               ` [Intel-wired-lan] " Nitesh Lal
2021-05-21  0:03               ` Nitesh Lal
2021-05-21  0:03                 ` [Intel-wired-lan] " Nitesh Lal
2021-05-21 11:56                 ` Thomas Gleixner
2021-05-21 11:56                   ` [Intel-wired-lan] " Thomas Gleixner
2021-05-21 12:03                   ` [PATCH] genirq: Provide new interfaces for affinity hints Thomas Gleixner
2021-05-21 12:03                     ` [Intel-wired-lan] " Thomas Gleixner
2021-05-21 15:45                     ` Lijun Pan
2021-05-21 15:45                       ` [Intel-wired-lan] " Lijun Pan
2021-05-21 21:45                       ` Thomas Gleixner
2021-05-21 21:45                         ` [Intel-wired-lan] " Thomas Gleixner
2021-05-21 16:13                     ` Nitesh Lal
2021-05-21 16:13                       ` [Intel-wired-lan] " Nitesh Lal
2021-05-21 21:48                       ` Thomas Gleixner
2021-05-21 21:48                         ` [Intel-wired-lan] " Thomas Gleixner
2021-06-04 20:35                         ` Nitesh Lal
2021-06-04 20:35                           ` [Intel-wired-lan] " Nitesh Lal
2021-05-27 10:03                     ` Shung-Hsi Yu
2021-05-27 10:03                       ` [Intel-wired-lan] " Shung-Hsi Yu
2021-05-27 10:21                       ` Shung-Hsi Yu
2021-05-27 10:21                         ` [Intel-wired-lan] " Shung-Hsi Yu
2021-05-27 13:06                       ` Nitesh Lal
2021-05-27 13:06                         ` [Intel-wired-lan] " Nitesh Lal
2021-05-28  7:20                         ` Shung-Hsi Yu
2021-05-28  7:20                           ` [Intel-wired-lan] " Shung-Hsi Yu
2021-06-07 17:00                     ` Nitesh Lal
2021-06-07 17:00                       ` [Intel-wired-lan] " Nitesh Lal
2021-06-14 16:12                       ` Nitesh Lal
2021-06-14 16:12                         ` [Intel-wired-lan] " Nitesh Lal
2021-05-21 13:46                   ` [PATCH tip:irq/core v1] genirq: remove auto-set of the mask when setting the hint Nitesh Lal
2021-05-21 13:46                     ` [Intel-wired-lan] " Nitesh Lal
2021-05-21 15:15                     ` Thomas Gleixner
2021-05-21 15:15                       ` [Intel-wired-lan] " Thomas Gleixner
2021-12-10 19:54 ` [tip: irq/core] genirq: Provide new interfaces for affinity hints tip-bot2 for Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.