All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Marco Crivellari <marco.crivellari@suse.com>
Cc: linux-kernel@vger.kernel.org,
	"Paul E . McKenney" <paulmck@kernel.org>,
	Ingo Molnar <mingo@kernel.org>, Michal Hocko <mhocko@suse.com>,
	Aaron Tomlin <atomlin@atomlin.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>
Subject: Re: [PATCH 2/3] sched/idle: Stop the tick on polling idle on nohz_full CPUs
Date: Fri, 6 Nov 2026 22:55:34 +0100	[thread overview]
Message-ID: <au5M1hKb2QuNd5bl@pavilion.home> (raw)
In-Reply-To: <20261106160621.347228-3-marco.crivellari@suse.com>

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@infradead.org>
> Cc: Juri Lelli <juri.lelli@redhat.com>
> Cc: Vincent Guittot <vincent.guittot@linaro.org>
> Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Ben Segall <bsegall@google.com>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: Valentin Schneider <vschneid@redhat.com>
> Cc: K Prateek Nayak <kprateek.nayak@amd.com>
> Link: https://lore.kernel.org/all/aQiWfnnSzxsnwa2o@tpad/
> Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
> ---
>  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.

Thanks.

> +{
> +	lockdep_assert_irqs_disabled();
> +
> +	if (tick_nohz_full_cpu(smp_processor_id()))
> +		tick_nohz_idle_stop_tick();
> +	else
> +		tick_nohz_idle_restart_tick();
> +}
> +
>  /**
>   * tick_nohz_idle_stop_tick - stop the idle tick from the idle task
>   *
> -- 
> 2.56.0
> 

-- 
Frederic Weisbecker
SUSE Labs

  reply	other threads:[~2026-11-06 21:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 16:06 [PATCH 0/3] Stop the idle tick on polling idle on nohz_full CPUs Marco Crivellari
2026-11-06 16:06 ` [PATCH 1/3] tick/nohz: Re-evaluate the tick on polling idle and on user entry Marco Crivellari
2026-11-06 22:15   ` Frederic Weisbecker
2026-11-09 17:24     ` Marco Crivellari
2026-11-10 13:33       ` Frederic Weisbecker
2026-11-10 17:35         ` Marco Crivellari
2026-11-11  9:59           ` Frederic Weisbecker
2026-11-06 16:06 ` [PATCH 2/3] sched/idle: Stop the tick on polling idle on nohz_full CPUs Marco Crivellari
2026-11-06 21:55   ` Frederic Weisbecker [this message]
2026-11-10  8:27     ` Marco Crivellari
2026-11-06 16:06 ` [PATCH 3/3] Documentation: no_hz: Add tick stop in polling idle Marco Crivellari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=au5M1hKb2QuNd5bl@pavilion.home \
    --to=frederic@kernel.org \
    --cc=atomlin@atomlin.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marco.crivellari@suse.com \
    --cc=mgorman@suse.de \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.