From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F7FF343D80 for ; Fri, 16 Jan 2026 20:05:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768593961; cv=none; b=tAZxT7OjQJGWwuz4WiEJAsqk12XNpfCxSt0Gg7+V6IHUEswDTxYBGLGeVoedrOtlX016+ye1txbSdRT26+rtCZ8vHG9wwnUvZy6Zq4FQuQy1eo/bt6ZOA1FZSVNFEfe9Yu6vUyhExgkhT1YWl7/YLGAiqo+rB7rMT1jJqtc/9S8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768593961; c=relaxed/simple; bh=37vZNW4JcLwWUR59K18mYARTccgZwmJWPnV1o5IW/UU=; h=From:Message-ID:Date:MIME-Version:Subject:To:Cc:References: In-Reply-To:Content-Type; b=GNWp6AGmGctXHKLxBL7bfAe9t6rxk/9sGMLkBKNULiWklye2uyusnkYR3Fp2DcQR9MbJpPU6Tewo72RE/yX5yyVjRs1wIJs+oMy//4UiMSf78RFE9VL3ceENHulCERtbEQvthJuP0m1ItVrnBi7rCjhYNomYT0Qw9IKIrIUFI2w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=G1VXPVtj; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Shx08uQd; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="G1VXPVtj"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Shx08uQd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768593959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GtPxWO6GzZ4EIV835FCZTdtnJQ4K/gParYVdXxrJhcQ=; b=G1VXPVtjtUwDP7W4Sox7u1RlXIeNFBdenYp/b3K7SmNQLyOijj2s5eDXw2PPyjzEMBg2wg a7c6XAuG/zpoK7J4Gk7CMtztnPkOYSVYTamNi/+lp8yr/+uCduMf0iFh1fTEbrzXkDtJFW 12RfwtbiKwykorXIspcY5AH+kpAON84= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-2U6be9P1OuaOrLsLZy0c5Q-1; Fri, 16 Jan 2026 15:05:55 -0500 X-MC-Unique: 2U6be9P1OuaOrLsLZy0c5Q-1 X-Mimecast-MFC-AGG-ID: 2U6be9P1OuaOrLsLZy0c5Q_1768593955 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-8c6a87029b6so252926185a.1 for ; Fri, 16 Jan 2026 12:05:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1768593955; x=1769198755; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:from:to :cc:subject:date:message-id:reply-to; bh=GtPxWO6GzZ4EIV835FCZTdtnJQ4K/gParYVdXxrJhcQ=; b=Shx08uQdM+ijJ8By0cDFgDSo1/GpVYtxeiCfcUEFulbwZG0P9LM1t5pw99di94ISLK h85I8Mxr6rHKl2MdKZ1tLL+p3V83WehP4fOJk9nNLK/LGJtXpABS6FmoxRSvOm6qYLHP +hKadDuDyRmMjOCOmxA7iMIoImzxKuPY/rEreqlad3hPaeppQbaDrGJeaJY9RcbIpZLx dNAO32LUwPMMwjLmWfTzaiJXUjSKXwZOBySjw4RYXhra53pbP1jDMsv/i4embhwsepEu r7xMF6NBWcrKYQ1AvBipauIWv4KSsEXBerEzM4JVZ7DzpJgfR8SJrA9i9+hJkct0IkkJ dqmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768593955; x=1769198755; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GtPxWO6GzZ4EIV835FCZTdtnJQ4K/gParYVdXxrJhcQ=; b=s5QL4S2Zb7jqfk7Yr16HJB5TsRLArRaj0y1VG8mHctTKxUpaUGcK207gAJTgN0sjbX cjRIgb5TUdC4KU+ychI+8CuZkewLyLvm4zl/po0wB3sEIMXVUVL2FnV/yjM7j14u4vJs VVZGrzes6sSwY+FEj5lS9FRTwNmIRUHpx04x7EVaZADDXVSR7GS8NTGCApXDop0E23fM /byIAsDz0s4+ickDf8vz0KvNEnrwAKMGzjcQaPCAf/SJgnmpO62EHRbYmO9pOPGQqaRQ DZX+VZolm2Bwy+mAUEBJ6u38oJeUpP30vY2fJxSmiPKgHcEDrIlymFnvDts2AsKwZSlA WY3g== X-Forwarded-Encrypted: i=1; AJvYcCWdsaSIAptpyxHrFYbOIlQwdh8y4yAzrxAWa0Ex7we9ctF/S7P1JTwPnPY45z8p0ZRewRrPFnFKX3UOiME=@vger.kernel.org X-Gm-Message-State: AOJu0YzOS2bAnv/NA4qmZpqpKU8FyJPvVeqt3XErxri5mpb+OeKOf0ZP Ep+g9v91flGCtFJtQVPq/o2mIewzUTXCsR2NkepUmlQw0zmsW9qQOmpYMOKYt/GsdZSjkgLNVXF J4jVNIG84Vb116mdm7NwVNTjUuSPDYWYV1phV0IwWe/CFcjWunL7KRyj03zNhmnW6kg== X-Gm-Gg: AY/fxX4wHeb9o+nwv/DPwtZnCKTxj9csJ+WNXBrXJZPTnp5miqU0X9ei42AimRJE64a HPbeAHtd5wMhAJHXZ0li9VxEEwjBeuWvJRaFuz7P5VUG+vtVCws5FqnTijlRz83i5sJfekJvhUk YZJOcUKSkn53oXvnBFmmECRKgA4pSEKOrVIyqISA8IOI1fVCwNCjfvnajxFavxo/aEMXjZJUzJ2 Ph2FQo7gc7uH1wGiPtps8Y685HaW5yPQzVsn2I5uRmlv9HBBfQbmO3SIzrd7G5c852ZA0ThmRcR gryOJFxbGptsTFKST+V8vigvQ3u4QE97MWoJR2h2HgEoJqyJ7t3cUzluVC6991JfVCkuvwfPw+/ pAphjh/tcOt/XgKEZBmzP5/V1lvSs3jZUdMKJfOegz8WLFYgCtHFvqi7a X-Received: by 2002:a05:620a:ac06:b0:8c6:aaf3:cb3a with SMTP id af79cd13be357-8c6aaf3cd90mr287363785a.85.1768593954769; Fri, 16 Jan 2026 12:05:54 -0800 (PST) X-Received: by 2002:a05:620a:ac06:b0:8c6:aaf3:cb3a with SMTP id af79cd13be357-8c6aaf3cd90mr287359885a.85.1768593954314; Fri, 16 Jan 2026 12:05:54 -0800 (PST) Received: from ?IPV6:2601:188:c102:b180:1f8b:71d0:77b1:1f6e? ([2601:188:c102:b180:1f8b:71d0:77b1:1f6e]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8c6a7263c91sm287213085a.45.2026.01.16.12.05.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Jan 2026 12:05:53 -0800 (PST) From: Waiman Long X-Google-Original-From: Waiman Long Message-ID: Date: Fri, 16 Jan 2026 15:05:52 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] clocksource: Use same threshold for read-back delay and time skew To: Jiri Wiesner , Linux Kernel Mailing List Cc: "Paul E. McKenney" , Feng Tang , John Stultz , Thomas Gleixner , Stephen Boyd References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/16/26 1:08 PM, Jiri Wiesner wrote: > 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 unstable because the skew is too large: > clocksource: 'hpet' wd_nsec: 479980680 wd_now: 1d86c0e1 wd_last: 1ccfa7c4 mask: ffffffff > clocksource: 'tsc' cs_nsec: 480489826 cs_now: 9d18bdd2c71b5 cs_last: 9d18ba107dfe9 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 { > > static enum wd_read_status cs_watchdog_read(struct clocksource *cs, u64 *csnow, u64 *wdnow) > { > - int64_t md = 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 clocksource *cs, u64 *csnow, > local_irq_enable(); > > wd_delay = cycles_to_nsec_safe(watchdog, *wdnow, wd_end); > - if (wd_delay <= md + cs->uncertainty_margin) { > + if (wd_delay <= watchdog->uncertainty_margin > + + cs->uncertainty_margin) { > if (nretries > 1 && nretries >= max_retries) { > pr_warn("timekeeping watchdog on CPU%d: %s retried %d times before success\n", > smp_processor_id(), watchdog->name, nretries); > @@ -280,12 +280,12 @@ static enum wd_read_status cs_watchdog_read(struct clocksource *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 = 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; > } > I think wd_seq_delay should compare to just one watchdog->uncertainty_margin. See my comment on a related patch sent out by Thomas. https://lore.kernel.org/lkml/8178bbf3-4a9d-4add-93bb-2ebd4dc03e9f@redhat.com/ Cheers, Longman