* [PATCH] tick/nohz: Requeue kicks flushed outside hardirq context
@ 2026-10-17 12:59 Peng Wang
2026-10-22 14:36 ` Frederic Weisbecker
0 siblings, 1 reply; 3+ messages in thread
From: Peng Wang @ 2026-10-17 12:59 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Ingo Molnar, Thomas Gleixner
Cc: Peng Wang, Peter Zijlstra, He Rongguang, linux-kernel
A remote nohz kick can be flushed from task context after idle exit
has checked tick dependencies. If polling suppressed the IPI, the empty
callback is consumed without an IRQ exit to reevaluate the tick. A newly
set dependency can then leave the non-idle tick stopped until another
interrupt arrives.
Requeue the work locally when it runs outside hardirq context on an
online CPU. This raises the IRQ needed for the existing tick reevaluation
path. Skip offline CPUs whose pending work is being drained during
teardown.
Fixes: 4b44a21dd640 ("irq_work, smp: Allow irq_work on call_single_queue")
Fixes: a5183862e76f ("tick/nohz: Conditionally restart tick on idle exit")
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>
---
kernel/time/tick-sched.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 6c3fea386713..87e2a7a87526 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -402,7 +402,12 @@ static bool can_stop_full_tick(int cpu, struct tick_sched *ts)
static void nohz_full_kick_func(struct irq_work *work)
{
- /* Empty, the tick restart happens on tick_nohz_irq_exit() */
+ /*
+ * Remote irq_work may be flushed from task context. Force an IRQ
+ * exit to reevaluate the tick unless this CPU is going offline.
+ */
+ if (!in_hardirq() && cpu_online(smp_processor_id()))
+ irq_work_queue(work);
}
static DEFINE_PER_CPU(struct irq_work, nohz_full_kick_work) =
base-commit: 70dd4ee72eb2d5793c62e71c14e3aba78e5a4e56
--
2.47.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tick/nohz: Requeue kicks flushed outside hardirq context
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
0 siblings, 1 reply; 3+ messages in thread
From: Frederic Weisbecker @ 2026-10-22 14:36 UTC (permalink / raw)
To: Peng Wang
Cc: Anna-Maria Behnsen, Ingo Molnar, Thomas Gleixner, Peter Zijlstra,
He Rongguang, linux-kernel
Le Sat, Oct 17, 2026 at 08:59:00PM +0800, Peng Wang a écrit :
> A remote nohz kick can be flushed from task context after idle exit
> has checked tick dependencies. If polling suppressed the IPI, the empty
> callback is consumed without an IRQ exit to reevaluate the tick. A newly
> set dependency can then leave the non-idle tick stopped until another
> interrupt arrives.
>
> Requeue the work locally when it runs outside hardirq context on an
> online CPU. This raises the IRQ needed for the existing tick reevaluation
> path. Skip offline CPUs whose pending work is being drained during
> teardown.
>
> Fixes: 4b44a21dd640 ("irq_work, smp: Allow irq_work on call_single_queue")
> Fixes: a5183862e76f ("tick/nohz: Conditionally restart tick on idle exit")
> 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>
> ---
> kernel/time/tick-sched.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
> index 6c3fea386713..87e2a7a87526 100644
> --- a/kernel/time/tick-sched.c
> +++ b/kernel/time/tick-sched.c
> @@ -402,7 +402,12 @@ static bool can_stop_full_tick(int cpu, struct tick_sched *ts)
>
> static void nohz_full_kick_func(struct irq_work *work)
> {
> - /* Empty, the tick restart happens on tick_nohz_irq_exit() */
> + /*
> + * Remote irq_work may be flushed from task context. Force an IRQ
> + * exit to reevaluate the tick unless this CPU is going offline.
> + */
> + if (!in_hardirq() && cpu_online(smp_processor_id()))
> + irq_work_queue(work);
Good catch but instead of requeuing, why not restarting the tick directly from
here instead of from IRQ exit?
Thanks.
> }
>
> static DEFINE_PER_CPU(struct irq_work, nohz_full_kick_work) =
>
> base-commit: 70dd4ee72eb2d5793c62e71c14e3aba78e5a4e56
> --
> 2.47.0
>
--
Frederic Weisbecker
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] tick/nohz: Reevaluate the tick for kicks flushed outside hardirq
2026-10-22 14:36 ` Frederic Weisbecker
@ 2026-10-22 17:54 ` Peng Wang
0 siblings, 0 replies; 3+ messages in thread
From: Peng Wang @ 2026-10-22 17:54 UTC (permalink / raw)
To: Anna-Maria Behnsen, Frederic Weisbecker, Ingo Molnar, Thomas Gleixner
Cc: Peter Zijlstra, He Rongguang, linux-kernel
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));
}
static DEFINE_PER_CPU(struct irq_work, nohz_full_kick_work) =
base-commit: 70dd4ee72eb2d5793c62e71c14e3aba78e5a4e56
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-22 17:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®