mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] genirq: Fix IRQ threads VS cpuset
@ 2025-11-18 14:30 Frederic Weisbecker
  2025-11-18 14:30 ` [PATCH 1/2] genirq: Fix IRQ threads affinity VS cpuset isolated partitions Frederic Weisbecker
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Frederic Weisbecker @ 2025-11-18 14:30 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Frederic Weisbecker, Marco Crivellari, Waiman Long, cgroups

Hi,

See here for previous patch:

	https://lore.kernel.org/lkml/20251105131726.46364-1-frederic@kernel.org/

Changes since v1:

* Remove handling of cpumask availability

Frederic Weisbecker (2):
  genirq: Fix IRQ threads affinity VS cpuset isolated partitions
  genirq: Remove cpumask availability check on kthread affinity setting

 kernel/irq/manage.c | 43 +++++++++++++++++--------------------------
 1 file changed, 17 insertions(+), 26 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 19+ messages in thread
* [PATCH 2/3 v3] genirq: Fix interrupt threads affinity vs. cpuset isolated partitions
@ 2025-11-21 14:34 Frederic Weisbecker
  2025-11-21 20:01 ` [tip: irq/core] " tip-bot2 for Frederic Weisbecker
  2025-11-22  8:30 ` tip-bot2 for Frederic Weisbecker
  0 siblings, 2 replies; 19+ messages in thread
From: Frederic Weisbecker @ 2025-11-21 14:34 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Frederic Weisbecker, Marek Szyprowski, Marco Crivellari,
	Waiman Long, cgroups

When a cpuset isolated partition is created / updated or destroyed, the
interrupt threads are affine blindly to all the non-isolated CPUs. And this
happens without taking into account the interrupt threads initial affinity
that becomes ignored.

For example in a system with 8 CPUs, if an interrupt and its kthread are
initially affine to CPU 5, creating an isolated partition with only CPU 2
inside will eventually end up affining the interrupt kthread to all CPUs
but CPU 2 (that is CPUs 0,1,3-7), losing the kthread preference for CPU 5.

Besides the blind re-affinity, this doesn't take care of the actual low
level interrupt which isn't migrated. As of today the only way to isolate
non managed interrupts, along with their kthreads, is to overwrite their
affinity separately, for example through /proc/irq/

To avoid doing that manually, future development should focus on updating
the interrupt's affinity whenever cpuset isolated partitions are updated.

In the meantime, cpuset shouldn't fiddle with interrupt threads directly.
To prevent from that, set the PF_NO_SETAFFINITY flag to them.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://patch.msgid.link/20251118143052.68778-2-frederic@kernel.org
---
 kernel/irq/manage.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index c1ce30c9c3ab..98b9b8b4de27 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1408,16 +1408,23 @@ setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary)
 	 * references an already freed task_struct.
 	 */
 	new->thread = get_task_struct(t);
+
 	/*
-	 * Tell the thread to set its affinity. This is
-	 * important for shared interrupt handlers as we do
-	 * not invoke setup_affinity() for the secondary
-	 * handlers as everything is already set up. Even for
-	 * interrupts marked with IRQF_NO_BALANCE this is
-	 * correct as we want the thread to move to the cpu(s)
-	 * on which the requesting code placed the interrupt.
+	 * The affinity may not yet be available, but it will be once
+	 * the IRQ will be enabled. Delay and defer the actual setting
+	 * to the thread itself once it is ready to run. In the meantime,
+	 * prevent it from ever being reaffined directly by cpuset or
+	 * housekeeping. The proper way to do it is to reaffine the whole
+	 * vector.
 	 */
-	set_bit(IRQTF_AFFINITY, &new->thread_flags);
+	kthread_bind_mask(t, cpu_possible_mask);
+
+	/*
+	 * Ensure the thread adjusts the affinity once it reaches the
+	 * thread function.
+	 */
+	new->thread_flags = BIT(IRQTF_AFFINITY);
+
 	return 0;
 }
 
-- 
2.51.1


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

end of thread, other threads:[~2025-11-22  8:30 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-18 14:30 [PATCH 0/2] genirq: Fix IRQ threads VS cpuset Frederic Weisbecker
2025-11-18 14:30 ` [PATCH 1/2] genirq: Fix IRQ threads affinity VS cpuset isolated partitions Frederic Weisbecker
2025-11-18 15:26   ` [tip: irq/core] genirq: Fix interrupt threads affinity vs. " tip-bot2 for Frederic Weisbecker
2025-11-18 16:27   ` [PATCH 1/2] genirq: Fix IRQ threads affinity VS " Waiman Long
2025-11-18 17:23     ` Thomas Gleixner
2025-11-18 17:29       ` Waiman Long
     [not found]   ` <CGME20251120115132eucas1p160658ba63831911aadd0b0c2f70b7e28@eucas1p1.samsung.com>
2025-11-20 11:51     ` Marek Szyprowski
2025-11-20 13:20       ` Frederic Weisbecker
2025-11-20 15:00         ` Thomas Gleixner
2025-11-20 15:50           ` Frederic Weisbecker
2025-11-20 19:09             ` Thomas Gleixner
2025-11-20 16:34           ` Marek Szyprowski
2025-11-20 13:45       ` Thomas Gleixner
2025-11-18 14:30 ` [PATCH 2/2] genirq: Remove cpumask availability check on kthread affinity setting Frederic Weisbecker
2025-11-18 15:26   ` [tip: irq/core] " tip-bot2 for Frederic Weisbecker
2025-11-18 15:14 ` [PATCH 0/2] genirq: Fix IRQ threads VS cpuset Thomas Gleixner
2025-11-18 17:44   ` Frederic Weisbecker
2025-11-21 14:34 [PATCH 2/3 v3] genirq: Fix interrupt threads affinity vs. cpuset isolated partitions Frederic Weisbecker
2025-11-21 20:01 ` [tip: irq/core] " tip-bot2 for Frederic Weisbecker
2025-11-22  8:30 ` tip-bot2 for Frederic Weisbecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®