mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Karl Mehltretter <kmehltretter@gmail.com>
To: Thomas Gleixner <tglx@kernel.org>,
	John Stultz <jstultz@google.com>, Stephen Boyd <sboyd@kernel.org>
Cc: Karl Mehltretter <kmehltretter@gmail.com>,
	Miroslav Lichvar <mlichvar@redhat.com>,
	Jiri Wiesner <jwiesner@suse.de>,
	Daniel J Blueman <daniel@quora.org>,
	regressions@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: [PATCH] clocksource: Prevent immediate watchdog rerun after a delay
Date: Mon, 26 Oct 2026 02:02:00 +0100	[thread overview]
Message-ID: <20261026010200.96371-1-kmehltretter@gmail.com> (raw)
In-Reply-To: <874ie9zc3g.ffs@fw13>

The watchdog rewrite made the clocksource check handle long intervals
between two measurements, but missed that the timer expiry needs to be
rebased after such a delay.

When a watchdog invocation is delayed by more than one interval, adding
WATCHDOG_INTERVAL to the previous expiry leaves the timer expiry in the
past. That causes an immediate second invocation. The resulting short
measurement interval can mark a clocksource unstable.

Cure this by rearming the timer based on jiffies, which places the next
expiry one full watchdog interval into the future.

Fixes: 763aacf86f1b ("clocksource: Rewrite watchdog code completely")
Closes: https://lore.kernel.org/r/20261010065509.72916-1-kmehltretter@gmail.com/
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
---
The baseline and patched builds used identical configs and initramfs
images. Tested on v7.3-rc5 (72d3fcf802c4) with four QEMU 8.2.2 TCG
vCPUs. PTRACE_ATTACH stopped only the vCPU 0 TCG thread for 800 ms,
six times 12 seconds apart per boot.

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

All 18 injected stalls completed for each kernel.

 kernel/time/clocksource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index f1253f5795c6e..58c0ca11cdc5a 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -673,7 +673,7 @@ static void clocksource_watchdog(struct timer_list *unused)
 
 	/* 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);
 	}
 }

base-commit: 5b0764a53235d3c77e1ed674e836e1b3fe1a4b1f
-- 
2.39.5 (Apple Git-154)


  reply	other threads:[~2026-10-26  1:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10  6:55 [REGRESSION] clocksource: delayed watchdog can mark TSC unstable Karl Mehltretter
2026-10-15 18:32 ` Thomas Gleixner
2026-10-22  5:43   ` Karl Mehltretter
2026-10-25 21:47     ` Thomas Gleixner
2026-10-26  1:02       ` Karl Mehltretter [this message]
2026-10-27 20:31         ` [tip: timers/urgent] clocksource: Prevent immediate watchdog rerun after a delay tip-bot2 for Karl Mehltretter

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=20261026010200.96371-1-kmehltretter@gmail.com \
    --to=kmehltretter@gmail.com \
    --cc=daniel@quora.org \
    --cc=jstultz@google.com \
    --cc=jwiesner@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlichvar@redhat.com \
    --cc=regressions@lists.linux.dev \
    --cc=sboyd@kernel.org \
    --cc=stable@vger.kernel.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 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®