Re: [PATCH 2/3] sched/idle: Stop the tick on polling idle on nohz_full CPUs
From: Marco Crivellari
Date: Tue Nov 10 2026 - 03:33:39 EST
On Fri, Nov 6, 2026 at 10:55 PM Frederic Weisbecker <frederic@xxxxxxxxxx> wrote:
>
> Le Fri, Nov 06, 2026 at 05:06:14PM +0100, Marco Crivellari a écrit :
> > With idle=poll, the tick fires while in user space, interrupting the task
> > running there. This is a problem when the CPU is nohz_full, as it
> > introduces noise into the workload.
> >
> > To fix this, stop the tick when entering polling idle on nohz_full CPUs,
> > while on other CPUs keep restarting it.
> >
> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Cc: Juri Lelli <juri.lelli@xxxxxxxxxx>
> > Cc: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> > Cc: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
> > Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
> > Cc: Ben Segall <bsegall@xxxxxxxxxx>
> > Cc: Mel Gorman <mgorman@xxxxxxx>
> > Cc: Valentin Schneider <vschneid@xxxxxxxxxx>
> > Cc: K Prateek Nayak <kprateek.nayak@xxxxxxx>
> > Link: https://lore.kernel.org/all/aQiWfnnSzxsnwa2o@tpad/
> > Signed-off-by: Marco Crivellari <marco.crivellari@xxxxxxxx>
> > ---
> > include/linux/tick.h | 2 ++
> > kernel/sched/idle.c | 5 ++++-
> > kernel/time/tick-sched.c | 18 ++++++++++++++++++
> > 3 files changed, 24 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/linux/tick.h b/include/linux/tick.h
> > index 8bfbb053f4fd..be4940f76777 100644
> > --- a/include/linux/tick.h
> > +++ b/include/linux/tick.h
> > @@ -129,6 +129,7 @@ extern bool tick_nohz_is_active(void);
> > extern bool tick_nohz_tick_stopped(void);
> > extern bool tick_nohz_tick_stopped_cpu(int cpu);
> > extern void tick_nohz_idle_stop_tick(void);
> > +extern void tick_nohz_full_idle_stop_tick(void);
> > extern void tick_nohz_idle_retain_tick(void);
> > extern void tick_nohz_idle_restart_tick(void);
> > extern void tick_nohz_idle_enter(void);
> > @@ -144,6 +145,7 @@ static inline bool tick_nohz_is_active(void) { return false; }
> > static inline int tick_nohz_tick_stopped(void) { return 0; }
> > static inline int tick_nohz_tick_stopped_cpu(int cpu) { return 0; }
> > static inline void tick_nohz_idle_stop_tick(void) { }
> > +static inline void tick_nohz_full_idle_stop_tick(void) { }
> > static inline void tick_nohz_idle_retain_tick(void) { }
> > static inline void tick_nohz_idle_restart_tick(void) { }
> > static inline void tick_nohz_idle_enter(void) { }
> > diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
> > index e0c10a5dbda2..226d02d24c73 100644
> > --- a/kernel/sched/idle.c
> > +++ b/kernel/sched/idle.c
> > @@ -349,7 +349,10 @@ static void do_idle(void)
> > * idle as we know that the IPI is going to arrive right away.
> > */
> > if (cpu_idle_force_poll || tick_check_broadcast_expired()) {
> > - tick_nohz_idle_restart_tick();
> > + if (cpu_idle_force_poll)
> > + tick_nohz_full_idle_stop_tick();
> > + else
> > + tick_nohz_idle_restart_tick();
> > cpu_idle_poll();
> > } else {
> > cpuidle_idle_call(got_tick);
> > diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
> > index a9f622fdeb12..3625ad9d2268 100644
> > --- a/kernel/time/tick-sched.c
> > +++ b/kernel/time/tick-sched.c
> > @@ -1179,6 +1179,24 @@ static bool can_stop_idle_tick(int cpu, struct tick_sched *ts)
> > return true;
> > }
> >
> > +/**
> > + * tick_nohz_full_idle_stop_tick - stop the tick on polling idle on NOHZ
> > + *
> > + * On nohz_full CPUs the tick restarted for polling idle would keep
> > + * running after idle exit and interrupt userspace once more; so stop it
> > + * instaed. On other CPUs, keep restarting it as before. Must be called
>
> *instead
>
> Also it should mention that we want to stop the tick before polling
> and not after because we don't want the tick stop induced latency after
> the task wake-up.
>
> > + * with interrupts disabled.
> > + */
> > +void tick_nohz_full_idle_stop_tick(void)
>
> I would rather call that tick_nohz_idle_poll_enter() because it is
> very specific and it's not just about stopping the nohz_full tick
> in idle, it's also restarting the tick if in dynticks-idle.
Sure, makes sense, I will change it.
Thanks,
--
Marco Crivellari
SUSE Labs