This is a note to let you know that I've just added the patch titled timers/nohz: Switch to ONESHOT_STOPPED in the low-res handler when the tick is stopped to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: timers-nohz-switch-to-oneshot_stopped-in-the-low-res-handler-when-the-tick-is-stopped.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From stable-owner@xxxxxxxxxxxxxxx Sun Aug 13 05:16:31 2023 From: "Joel Fernandes (Google)" <joel@xxxxxxxxxxxxxxxxx> Date: Sun, 13 Aug 2023 03:16:19 +0000 Subject: timers/nohz: Switch to ONESHOT_STOPPED in the low-res handler when the tick is stopped To: stable@xxxxxxxxxxxxxxx Cc: Guenter Roeck <linux@xxxxxxxxxxxx>, Steven Rostedt <rostedt@xxxxxxxxxxx>, Nicholas Piggin <npiggin@xxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Joel Fernandes <joel@xxxxxxxxxxxxxxxxx> Message-ID: <20230813031620.2218302-2-joel@xxxxxxxxxxxxxxxxx> From: Nicholas Piggin <npiggin@xxxxxxxxx> [ Upstream commit 62c1256d544747b38e77ca9b5bfe3a26f9592576 ] When tick_nohz_stop_tick() stops the tick and high resolution timers are disabled, then the clock event device is not put into ONESHOT_STOPPED mode. This can lead to spurious timer interrupts with some clock event device drivers that don't shut down entirely after firing. Eliminate these by putting the device into ONESHOT_STOPPED mode at points where it is not being reprogrammed. When there are no timers active, then tick_program_event() with KTIME_MAX can be used to stop the device. When there is a timer active, the device can be stopped at the next tick (any new timer added by timers will reprogram the tick). Signed-off-by: Nicholas Piggin <npiggin@xxxxxxxxx> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20220422141446.915024-1-npiggin@xxxxxxxxx Signed-off-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- kernel/time/tick-sched.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -950,6 +950,8 @@ static void tick_nohz_stop_tick(struct t if (unlikely(expires == KTIME_MAX)) { if (ts->nohz_mode == NOHZ_MODE_HIGHRES) hrtimer_cancel(&ts->sched_timer); + else + tick_program_event(KTIME_MAX, 1); return; } @@ -1356,9 +1358,15 @@ static void tick_nohz_handler(struct clo tick_sched_do_timer(ts, now); tick_sched_handle(ts, regs); - /* No need to reprogram if we are running tickless */ - if (unlikely(ts->tick_stopped)) + if (unlikely(ts->tick_stopped)) { + /* + * The clockevent device is not reprogrammed, so change the + * clock event device to ONESHOT_STOPPED to avoid spurious + * interrupts on devices which might not be truly one shot. + */ + tick_program_event(KTIME_MAX, 1); return; + } hrtimer_forward(&ts->sched_timer, now, TICK_NSEC); tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1); Patches currently in stable-queue which might be from stable-owner@xxxxxxxxxxxxxxx are queue-5.15/tick-detect-and-fix-jiffies-update-stall.patch queue-5.15/timers-nohz-last-resort-update-jiffies-on-nohz_full-irq-entry.patch queue-5.15/timers-nohz-switch-to-oneshot_stopped-in-the-low-res-handler-when-the-tick-is-stopped.patch queue-5.15/netfilter-nf_tables-report-use-refcount-overflow.patch