Re: [REGRESSION] clocksource: delayed watchdog can mark TSC unstable

From: Karl Mehltretter

Date: Thu Oct 22 2026 - 01:43:21 EST


On Thu, Oct 15, 2026 at 08:32:25PM +0100, Thomas Gleixner wrote:
> > busybox-79 [000] ..s1. 15.168486: clocksource_watchdog <-call_timer_fn
> > busybox-79 [000] .Ns.. 16.269726: clocksource_watchdog <-call_timer_fn
> > busybox-79 [000] .Ns.. 16.269820: clocksource_watchdog <-call_timer_fn
>
> I did not think about that scenario obvioulsy. The code is resilient
> against long intervals between two measurements, so the easy and
> straight forward fix is indeed what you (or the LLM) suggested.
>
> Thanks,
>
> tglx
> ---
> --- a/kernel/time/clocksource.c
> +++ b/kernel/time/clocksource.c
> @@ -673,7 +673,7 @@ static void clocksource_watchdog(struct
>
> /* Could have been rearmed by a stop/start cycle */
> if (!timer_pending(&watchdog_timer)) {
> - watchdog_timer.expires += WATCHDOG_INTERVAL;
> + watchdog_timer.expires = jiffies + WATCHDOG_INTERVAL;
> add_timer_local(&watchdog_timer);
> }
> }

Yes, I tested this change on v7.3-rc5 (72d3fcf802c4)

baseline patched
TSC marked unstable 2/3 boots 0/3 boots
watchdog gaps below 250 ms 3/3 boots 0/3 boots
minimum traced gap 0.231 ms 505.484 ms

Each boot had four QEMU TCG vCPUs. I used PTRACE_ATTACH to
stop only the vCPU 0 TCG thread for 800 ms.

Thanks,
Karl