Re: [PATCH 1/3] tick/nohz: Re-evaluate the tick on polling idle and on user entry
From: Marco Crivellari
Date: Tue Nov 10 2026 - 12:44:39 EST
On Tue, Nov 10, 2026 at 2:33 PM Frederic Weisbecker <frederic@xxxxxxxxxx> wrote:
> [...]
> > With the hunk, the stopped tick firing for the first timer sets
> > TIF_NEED_RESCHED, the polling loop exits and the tick is reprogrammed
> > for the second timer within a few microseconds; the 10 iterations
> > captured take 0.92s instead of ~18s. Without that hunk, the CPU stops
> > spinning on an unrelated event.
> >
> > So in my understanding tick_nohz_idle_exit() program the tick only for
> > the earliest timer; when it expire, the tick is stopped and not
> > rearmed in tick_nohz_handler() (HRTIMER_NORESTART). Without setting
> > NEED_RESCHED if another timer has been queued it has to wait for
> > another event that set NEED_RESCHED.
>
> Hehe, you're right :)
>
> Let's try another strategy then. TS_FLAG_INIDLE is what tells nohz_fool whether
> to manage the tick through the idle loop or through the IRQ exit.
>
> So why not calling tick_nohz_idle_enter() on each idle loop iterations? That is,
> from cpuidle_idle_call(). And call tick_nohz_idle_exit() right before
> cpu_idle_poll()?
Aha, sounds good! :-) So INIDLE is set only when really "in idle" (eg
no polling).
> Then you can remove tick_nohz_idle_restart_tick().
Should we remove only the call or also the function and its declaration?
I'm asking because the call we're going to remove is the only one present.
> Just be careful: tick_nohz_idle_enter() and tick_nohz_idle_exit() may now be
> unbalanced. If TS_FLAG_INIDLE is already set, tick_nohz_idle_enter() should
> return early and tick_nohz_idle_exit() as well if !TS_FLAG_INIDLE.
>
> Also IRQs may now be disabled while calling tick_nohz_idle_exit(), so it should
> use local_irq_save() and not local_irq_disable(). OTOH tick_nohz_idle_enter()
> should always expect IRQs disabled.
>
> So the purpose is to move cpu_idle_poll() outside the dynticks idle logic, then
> it's safe against nohz_full timer management, the tick keeps being stopped if
> possible and it's only restarted for dynticks idle.
Ok, I think it's clear.
I've already started implementing the changes. I will send v2 with all
the changes.
Thank you!
--
Marco Crivellari
SUSE Labs