All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Peng Wang <peng_wang@linux.alibaba.com>
Cc: Anna-Maria Behnsen <anna-maria@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, Thomas Gleixner <tglx@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	He Rongguang <herongguang@linux.alibaba.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] tick/nohz: Reevaluate the tick for kicks flushed outside hardirq
Date: Fri, 23 Oct 2026 15:31:26 +0200	[thread overview]
Message-ID: <atthrrwRchO2FL8g@localhost.localdomain> (raw)
In-Reply-To: <20261022175500.15940-1-peng_wang@linux.alibaba.com>

Le Fri, Oct 23, 2026 at 01:54:57AM +0800, Peng Wang a écrit :
> The nohz full kick relies on IRQ exit to reevaluate the tick. However,
> a remote kick can also be flushed from task context without an IRQ
> exit guaranteed to follow. If a tick dependency is set or an earlier
> timer is queued after the idle-exit reevaluation, the required tick
> update can be delayed until another interrupt.
> 
> Reevaluate the tick directly from the callback outside hardirq context.
> Keep the existing IRQ-exit handling for hardirq callbacks. The offline
> flush remains harmless because tick_sched_timer_dying() has already
> cleared TS_FLAG_NOHZ.
> 
> Fixes: 4b44a21dd640 ("irq_work, smp: Allow irq_work on call_single_queue")
> Fixes: a5183862e76f ("tick/nohz: Conditionally restart tick on idle exit")
> Suggested-by: Frederic Weisbecker <frederic@kernel.org>
> Co-developed-by: He Rongguang <herongguang@linux.alibaba.com>
> Signed-off-by: He Rongguang <herongguang@linux.alibaba.com>
> Signed-off-by: Peng Wang <peng_wang@linux.alibaba.com>
> ---
> Changes in v2:
> - Reevaluate the tick directly outside hardirq instead of requeueing,
>   as suggested by Frederic.
> - Use the full update for both dependencies and timer deadlines. Keep
>   IRQ-exit handling for hardirq callbacks and the existing NOHZ guard
>   for CPU teardown.
> 
> v1: https://lore.kernel.org/all/43668cf88d976084e2865ec07dea82b64ad402ba.1792240863.git.peng_wang@linux.alibaba.com/
> 
>  kernel/time/tick-sched.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
> index 6c3fea386713..ece2c21cec84 100644
> --- a/kernel/time/tick-sched.c
> +++ b/kernel/time/tick-sched.c
> @@ -400,9 +400,13 @@ static bool can_stop_full_tick(int cpu, struct tick_sched *ts)
>  	return true;
>  }
>  
> +static void tick_nohz_full_update_tick(struct tick_sched *ts);
> +
>  static void nohz_full_kick_func(struct irq_work *work)
>  {
> -	/* Empty, the tick restart happens on tick_nohz_irq_exit() */
> +	/* Task-context flushes may not be followed by an IRQ exit. */
> +	if (!in_hardirq())
> +		tick_nohz_full_update_tick(this_cpu_ptr(&tick_cpu_sched));

Just in case, even though it shouldn't happen, just have the following sanity
checks to return early:

if (WARN_ON_ONCE(!tick_nohz_full_cpu(smp_processor_id())))
    return;

if (!in_hardirq()) {
    if (WARN_ON_ONCE(tick_sched_flag_test(ts, TS_FLAG_INIDLE)))
       return;
    tick_nohz_full_update_tick(this_cpu_ptr(&tick_cpu_sched));
}

Thanks!

>  }
>  
>  static DEFINE_PER_CPU(struct irq_work, nohz_full_kick_work) =
> 
> base-commit: 70dd4ee72eb2d5793c62e71c14e3aba78e5a4e56
> -- 
> 2.47.3
> 

-- 
Frederic Weisbecker
SUSE Labs

  reply	other threads:[~2026-10-23 13:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-17 12:59 [PATCH] tick/nohz: Requeue kicks flushed outside hardirq context Peng Wang
2026-10-22 14:36 ` Frederic Weisbecker
2026-10-22 17:54   ` [PATCH v2] tick/nohz: Reevaluate the tick for kicks flushed outside hardirq Peng Wang
2026-10-23 13:31     ` Frederic Weisbecker [this message]
2026-10-23 14:51       ` [PATCH v3] " Peng Wang
2026-10-23 15:07         ` Frederic Weisbecker
2026-10-25 21:47         ` [tip: timers/urgent] " tip-bot2 for Peng Wang

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=atthrrwRchO2FL8g@localhost.localdomain \
    --to=frederic@kernel.org \
    --cc=anna-maria@linutronix.de \
    --cc=herongguang@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peng_wang@linux.alibaba.com \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    /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.