Skip to contentSkip to conversation

genirq: Update effective affinity for redirected interrupts

PATCH Applied Radu Rendec 3 participants 3 messages Jan 12 – Jan 13

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 genirq: Update effective affinity for redirected interrupts

For redirected interrupts, irq_chip_redirect_set_affinity() does not update the effective affinity mask, which then triggers the warning in irq_validate_effective_affinity(). Also, because the effective affinity mask is empty, the cpumask_test_cpu(smp_processor_id(), m) condition in demux_redirect_remote() is always false, and the interrupt is always redirected, even if it's already running on the target CPU.

Set the effective affinity mask to be the same as the requested affinity mask. It's worth noting that irq_do_set_affinity() filters out offline CPUs before calling chip->irq_set_affinity() (unless force is set), so the mask passed to irq_chip_redirect_set_affinity() is already filtered.

The solution is not ideal because it may lie about the effective affinity of the demultiplexed ("child") interrupt. If the requested affinity mask includes multiple CPUs, the effective affinity, in reality, is the intersection between the requested mask and the demultiplexing ("parent") interrupt's effective affinity mask, plus the first CPU in the requested mask.

Accurately describing the effective affinity of the demultiplexed interrupt is not trivial because it requires keeping track of the demultiplexing interrupt's effective affinity. That is tricky in the context of CPU hot(un)plugging, where interrupt migration ordering is not guaranteed. The solution in the initial version of the fixed patch, which stored the first CPU of the demultiplexing interrupt's effective affinity in the target_cpu field, has its own drawbacks and limitations.

Fixes fcc1d0dabdb6 ("genirq: Add interrupt redirection infrastructure")
---
 kernel/irq/chip.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/irq/chip.c +2 -0
index 433f1dd2b0ca7..35bc17bc369e0 100644
@@ -1493,6 +1493,8 @@ int irq_chip_redirect_set_affinity(struct irq_data *data, const struct cpumask *
 	struct irq_redirect *redir = &irq_data_to_desc(data)->redirect;
 
 	WRITE_ONCE(redir->target_cpu, cpumask_first(dest));
+	irq_data_update_effective_affinity(data, dest);
+
 	return IRQ_SET_MASK_OK;
 }
 EXPORT_SYMBOL_GPL(irq_chip_redirect_set_affinity);
Signature · 1 line
2.52.0
maintainer Tested-by on v1 1/1
#1 lore raw
Quoted 41 lines · Radu Rendec

For redirected interrupts, irq_chip_redirect_set_affinity() does not update the effective affinity mask, which then triggers the warning in irq_validate_effective_affinity(). Also, because the effective affinity mask is empty, the cpumask_test_cpu(smp_processor_id(), m) condition in demux_redirect_remote() is always false, and the interrupt is always redirected, even if it's already running on the target CPU.

Set the effective affinity mask to be the same as the requested affinity mask. It's worth noting that irq_do_set_affinity() filters out offline CPUs before calling chip->irq_set_affinity() (unless force is set), so the mask passed to irq_chip_redirect_set_affinity() is already filtered.

The solution is not ideal because it may lie about the effective affinity of the demultiplexed ("child") interrupt. If the requested affinity mask includes multiple CPUs, the effective affinity, in reality, is the intersection between the requested mask and the demultiplexing ("parent") interrupt's effective affinity mask, plus the first CPU in the requested mask.

Accurately describing the effective affinity of the demultiplexed interrupt is not trivial because it requires keeping track of the demultiplexing interrupt's effective affinity. That is tricky in the context of CPU hot(un)plugging, where interrupt migration ordering is not guaranteed. The solution in the initial version of the fixed patch, which stored the first CPU of the demultiplexing interrupt's effective affinity in the target_cpu field, has its own drawbacks and limitations.

Fixes fcc1d0dabdb6 ("genirq: Add interrupt redirection infrastructure")
---
  kernel/irq/chip.c | 2 ++
  1 file changed, 2 insertions(+)
kernel/irq/chip.c +0 -0
index 433f1dd2b0ca7..35bc17bc369e0 100644

kernel/irq/chip.c int irq_chip_redirect_set_affinity(struct irq_data *data, const struct cpumask * · line 1500

Quoted 8 lines
kernel/irq/chip.c +2 -0
@@ -1493,6 +1493,8 @@ int irq_chip_redirect_set_affinity(struct irq_data *data, const struct cpumask *
  	struct irq_redirect *redir = &irq_data_to_desc(data)->redirect;
 
  	WRITE_ONCE(redir->target_cpu, cpumask_first(dest));
+	irq_data_update_effective_affinity(data, dest);
+
  	return IRQ_SET_MASK_OK;
  }
  EXPORT_SYMBOL_GPL(irq_chip_redirect_set_affinity);

This is working for me ...

Thanks
Jon

Signature · 1 line
nvpublic
merge bot Applied
#2 lore raw
In reply to Radu Rendec
The following commit has been merged into the irq/msi branch of tip:

The following commit has been merged into the irq/msi branch of tip:

Commit-ID:     df439718afaf23b5aa7b5711b6c14e87b5836cae
Gitweb:        https://git.kernel.org/tip/df439718afaf23b5aa7b5711b6c14e87b5836cae
Author:        Radu Rendec <[email protected]>
AuthorDate:    Mon, 12 Jan 2026 16:14:02 -05:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Tue, 13 Jan 2026 09:59:28 +01:00

genirq: Update effective affinity for redirected interrupts

For redirected interrupts, irq_chip_redirect_set_affinity() does not update the effective affinity mask, which then triggers the warning in irq_validate_effective_affinity(). Also, because the effective affinity mask is empty, the cpumask_test_cpu(smp_processor_id(), m) condition in demux_redirect_remote() is always false, and the interrupt is always redirected, even if it's already running on the target CPU.

Set the effective affinity mask to be the same as the requested affinity mask. It's worth noting that irq_do_set_affinity() filters out offline CPUs before calling chip->irq_set_affinity() (unless force is set), so the mask passed to irq_chip_redirect_set_affinity() is already filtered.

The solution is not ideal because it may lie about the effective affinity of the demultiplexed ("child") interrupt. If the requested affinity mask includes multiple CPUs, the effective affinity, in reality, is the intersection between the requested mask and the demultiplexing ("parent") interrupt's effective affinity mask, plus the first CPU in the requested mask.

Accurately describing the effective affinity of the demultiplexed interrupt is not trivial because it requires keeping track of the demultiplexing interrupt's effective affinity. That is tricky in the context of CPU hot(un)plugging, where interrupt migration ordering is not guaranteed. The solution in the initial version of the fixed patch, which stored the first CPU of the demultiplexing interrupt's effective affinity in the target_cpu field, has its own drawbacks and limitations.

---
 kernel/irq/chip.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/irq/chip.c +2 -0
index 433f1dd..35bc17b 100644
@@ -1493,6 +1493,8 @@ int irq_chip_redirect_set_affinity(struct irq_data *data, const struct cpumask *
 	struct irq_redirect *redir = &irq_data_to_desc(data)->redirect;
 
 	WRITE_ONCE(redir->target_cpu, cpumask_first(dest));
+	irq_data_update_effective_affinity(data, dest);
+
 	return IRQ_SET_MASK_OK;
 }
 EXPORT_SYMBOL_GPL(irq_chip_redirect_set_affinity);