From nobody Sun Feb 8 04:11:34 2026 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81FD92F691D for ; Fri, 16 Jan 2026 18:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768586901; cv=none; b=oP8kTW8FBsTPHemdQs8Xih/hCjv0A/ea4S3Cl5fyCIW6PNHmvYTJTK54XjRvRv7MnttqxQ4Az87bkBm0agWtpP5VggwgpBJnKVSHs1cuQQnengEWcZHmj6Po5FJ0fbycIzKDk3V+RKnZl9aAQ8d3j5qSrcs3CfKP5X+md5qpviI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768586901; c=relaxed/simple; bh=MU0AmjN1Iwbs8HOtzaZAwExnOoT1aIKc/Pohoi7q4ik=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=JQ3wczEU9AZJ81h1VwGxpVpafpvA+Bkw016aq4B03FsV9LrW65gklMP/LBzX3KwwXxsjFxb/bc80bdpH51lSinvFL817lVbKIVJqOHKj4PAdWJm/fuFbdscuXUMkHKIYn/nasDWIXTO5lOOJMRvy/v/FhFogmP/TvMu9IOKR3kU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=PwDnkJhd; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=ZR8iZhB+; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=PwDnkJhd; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=ZR8iZhB+; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="PwDnkJhd"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ZR8iZhB+"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="PwDnkJhd"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ZR8iZhB+" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B75F3336B0; Fri, 16 Jan 2026 18:08:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1768586897; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=+TIgVhteikUHaOqhlvXEOWyqHO2Lfc/eeDU1LnkGUR4=; b=PwDnkJhdVIgEqA0mlMAFowT2z9bjhFFlowNy+VMO7R7Rbw2b5m3xySg8KS3duG022MeoQe I0PU1lNH+hgOK18agbjoyLqVXb8jUCywSNQI/SAXpCi03D0HdL9dsYyO1+fi14VWM0Yc8W NxjQDJeDXZ0MtpBbg359wP1yXytOXOY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1768586897; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=+TIgVhteikUHaOqhlvXEOWyqHO2Lfc/eeDU1LnkGUR4=; b=ZR8iZhB+s0+iNN6j1ZTuMDOqg/oULXwHH3SWcPcWCwPjENbk7t+jfr18qfdezBwFhRNhWc 8shN9nXJ6l8OWfCA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=PwDnkJhd; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=ZR8iZhB+ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1768586897; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=+TIgVhteikUHaOqhlvXEOWyqHO2Lfc/eeDU1LnkGUR4=; b=PwDnkJhdVIgEqA0mlMAFowT2z9bjhFFlowNy+VMO7R7Rbw2b5m3xySg8KS3duG022MeoQe I0PU1lNH+hgOK18agbjoyLqVXb8jUCywSNQI/SAXpCi03D0HdL9dsYyO1+fi14VWM0Yc8W NxjQDJeDXZ0MtpBbg359wP1yXytOXOY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1768586897; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=+TIgVhteikUHaOqhlvXEOWyqHO2Lfc/eeDU1LnkGUR4=; b=ZR8iZhB+s0+iNN6j1ZTuMDOqg/oULXwHH3SWcPcWCwPjENbk7t+jfr18qfdezBwFhRNhWc 8shN9nXJ6l8OWfCA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A8F0E3EA63; Fri, 16 Jan 2026 18:08:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ElA4KZF+amn/RAAAD6G6ig (envelope-from ); Fri, 16 Jan 2026 18:08:17 +0000 Received: by incl.suse.cz (Postfix, from userid 1000) id 7E0F2F3CD5; Fri, 16 Jan 2026 19:08:16 +0100 (CET) Date: Fri, 16 Jan 2026 19:08:16 +0100 From: Jiri Wiesner To: Linux Kernel Mailing List Cc: "Paul E. McKenney" , Feng Tang , Waiman Long , John Stultz , Thomas Gleixner , Stephen Boyd Subject: [PATCH] clocksource: Use same threshold for read-back delay and time skew Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_SEVEN(0.00)[7]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_ALL(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MISSING_XM_UA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Spam-Flag: NO X-Spam-Score: -4.01 X-Rspamd-Queue-Id: B75F3336B0 X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spam-Level: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The idea behind using the uncertainty margins of clocksources to set the threshold for checking read-back delay is a sound one. For 3 clocksource readouts, 3 uncertainty margins are added up to calcute a read-back delay threshold. The read-back delay threshold: 2 * watchdog->uncertainty_margin + cs->uncertainty_margin is always larger than the threshold for evaluating time skew: watchdog->uncertainty_margin + cs->uncertainty_margin When an SMI or NMI is received between the first watchdog read and the clocksource read and servicing this interrupt takes more time than the threshold for evaluating time skew but also less time than read-back delay threshold, the readouts will pass the read-back delay threshold but the clocksource watchdog will mark the clocksource unstable on account of time skew. This decision is incorrect. Instead, another iteration of the loop in cs_watchdog_read() should execute the readouts again (should there be any iterations left). Correct the situation by decreasing the read-back delay threshold to a value equal to the time skew threshold. This patch resolves an issue observed on a production machine: clocksource: timekeeping watchdog on CPU556: Marking clocksource 'tsc' as u= nstable because the skew is too large: clocksource: 'hpet' wd_nsec: 479980680 wd_now: 1d86c0e1 wd_last: 1ccfa7c4 m= ask: ffffffff clocksource: 'tsc' cs_nsec: 480489826 cs_now: 9d18bdd2c71b5 cs_last: 9d18ba= 107dfe9 mask: ffffffffffffffff clocksource: Clocksource 'tsc' skewed 509146 ns (0 ms) over watchdog 'hpet'= interval of 479980680 ns (479 ms) clocksource: 'tsc' is current clocksource. tsc: Marking TSC unstable due to clocksource watchdog Fixes: 4ac1dd3245b9 ("clocksource: Set cs_watchdog_read() checks based on .= uncertainty_margin") Signed-off-by: Jiri Wiesner --- kernel/time/clocksource.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c index a1890a073196..31add3e40c12 100644 --- a/kernel/time/clocksource.c +++ b/kernel/time/clocksource.c @@ -252,7 +252,6 @@ enum wd_read_status { =20 static enum wd_read_status cs_watchdog_read(struct clocksource *cs, u64 *c= snow, u64 *wdnow) { - int64_t md =3D 2 * watchdog->uncertainty_margin; unsigned int nretries, max_retries; int64_t wd_delay, wd_seq_delay; u64 wd_end, wd_end2; @@ -267,7 +266,8 @@ static enum wd_read_status cs_watchdog_read(struct cloc= ksource *cs, u64 *csnow, local_irq_enable(); =20 wd_delay =3D cycles_to_nsec_safe(watchdog, *wdnow, wd_end); - if (wd_delay <=3D md + cs->uncertainty_margin) { + if (wd_delay <=3D watchdog->uncertainty_margin + + cs->uncertainty_margin) { if (nretries > 1 && nretries >=3D max_retries) { pr_warn("timekeeping watchdog on CPU%d: %s retried %d times before suc= cess\n", smp_processor_id(), watchdog->name, nretries); @@ -280,12 +280,12 @@ static enum wd_read_status cs_watchdog_read(struct cl= ocksource *cs, u64 *csnow, * there is too much external interferences that cause * significant delay in reading both clocksource and watchdog. * - * If consecutive WD read-back delay > md, report - * system busy, reinit the watchdog and skip the current - * watchdog test. + * If consecutive WD read-back delay is greater than + * 2 * watchdog->uncertainty_margin, report system busy, + * reinit the watchdog and skip the current watchdog test. */ wd_seq_delay =3D cycles_to_nsec_safe(watchdog, wd_end, wd_end2); - if (wd_seq_delay > md) + if (wd_seq_delay > 2 * watchdog->uncertainty_margin) goto skip_test; } =20 --=20 2.51.0 --=20 Jiri Wiesner SUSE Labs