Re: [PATCH 2/2] softirq: Treat an interrupted idle task as idle in tick_irq_exit()

From: Peter Zijlstra

Date: Fri Nov 06 2026 - 05:36:48 EST


On Fri, Nov 06, 2026 at 09:43:43AM +0000, Radu Toader wrote:
> diff --git a/kernel/softirq.c b/kernel/softirq.c
> index 7fc2200392cd..e7d649c29c0c 100644
> --- a/kernel/softirq.c
> +++ b/kernel/softirq.c
> @@ -738,8 +738,16 @@ static inline void tick_irq_exit(void)
> #ifdef CONFIG_NO_HZ_COMMON
> int cpu = smp_processor_id();
>
> + /*
> + * Make sure that timer wheel updates are propagated. An interrupted
> + * idle loop counts as idle even with runnable tasks queued on the
> + * CPU: forced idle under core scheduling, and the tasks sched_ext
> + * keeps on a CPU's run queue while its BPF scheduler holds them back.
> + * idle_cpu() would skip the idle bookkeeping of tick_nohz_irq_exit()
> + * for those, and with an unstable sched_clock the CPU's clock then
> + * isn't resynchronized when it leaves the idle loop.
> + */
> + if ((is_idle_task(current) && !need_resched()) || tick_nohz_full_cpu(cpu)) {

So is_idle_task() is also true for idle-injection tasks. I *think* that
is also right in this case, but it wasn't mentioned.

That is, we can have tasks that are not rq->idle for which
is_idle_task()/PF_IDLE is true, those tasks will also 'run' an idle
state, see play_idle_precise() and its users.

> if (hardirq_count() == HARDIRQ_OFFSET)
> tick_nohz_irq_exit();
> }
> --
> 2.43.0
>