Re: [PATCH 2/3 v3] genirq: Fix interrupt threads affinity vs. cpuset isolated partitions
From: Chris Mason
Date: Thu Dec 11 2025 - 20:51:37 EST
On Fri, 21 Nov 2025 15:34:59 +0100 Frederic Weisbecker <frederic@xxxxxxxxxx> wrote:
Hi everyone,
I ran some recent commits through AI patch review and it flagged this one.
The comments below looks right to me, but I might be missing something:
> diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
> index c1ce30c9c3ab6..61da1c68ff82a 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);
[ ... ]
> - 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);
^^^
Can this clobber IRQTF_FORCED_THREAD?
In __setup_irq(), irq_setup_forced_threading() is called before
setup_irq_thread(). When forced threading is enabled,
irq_setup_forced_threading() sets IRQTF_FORCED_THREAD via set_bit():
set_bit(IRQTF_FORCED_THREAD, &new->thread_flags);
Then setup_irq_thread() overwrites thread_flags with a direct assignment:
new->thread_flags = BIT(IRQTF_AFFINITY);
This clears IRQTF_FORCED_THREAD. Later in irq_thread():
if (force_irqthreads() && test_bit(IRQTF_FORCED_THREAD,
&action->thread_flags))
handler_fn = irq_forced_thread_fn;
else
handler_fn = irq_thread_fn;
Without IRQTF_FORCED_THREAD, the handler uses irq_thread_fn() instead of
irq_forced_thread_fn(). The forced-threaded handler then runs without the
local_bh_disable() and local_irq_disable() protection that non-threaded
interrupt handlers expect.
Should this be:
new->thread_flags |= BIT(IRQTF_AFFINITY);
or:
set_bit(IRQTF_AFFINITY, &new->thread_flags);
> +
> return 0;
> }
-chris