Re: [PATCH 2/3 v3] genirq: Fix interrupt threads affinity vs. cpuset isolated partitions
From: Thomas Gleixner
Date: Thu Dec 11 2025 - 21:26:43 EST
On Thu, Dec 11 2025 at 17:48, Chris Mason wrote:
> On Fri, 21 Nov 2025 15:34:59 +0100 Frederic Weisbecker <frederic@xxxxxxxxxx> wrote:
> 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():
Yep. That's broken. Nice catch.