From: "Paul E. McKenney" <paulmck@kernel.org>
To: Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
John Stultz <jstultz@google.com>, Stephen Boyd <sboyd@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Feng Tang <feng.tang@intel.com>, Waiman Long <longman@redhat.com>,
Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>,
x86@kernel.org, kernel-team@meta.com,
linux-kernel@vger.kernel.org,
"Paul E . McKenney" <paulmck@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH v2 TSC and clocksource-watchdog updates for v6.12 1/5] clocksource: Improve comments for watchdog skew bounds
Date: Fri, 2 Aug 2024 08:46:14 -0700 [thread overview]
Message-ID: <20240802154618.4149953-1-paulmck@kernel.org> (raw)
In-Reply-To: <dac058b2-68c7-4b9a-a428-afb2b4b03ea0@paulmck-laptop>
From: Borislav Petkov <bp@alien8.de>
Add more detail on the rationale for bounding the clocksource
->uncertainty_margin below at about 500ppm.
Signed-off-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: John Stultz <jstultz@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Feng Tang <feng.tang@intel.com>
---
kernel/time/clocksource.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index d25ba49e313cc..9ca4e8d2a70f8 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -125,6 +125,13 @@ static u64 suspend_start;
*
* The default of 500 parts per million is based on NTP's limits.
* If a clocksource is good enough for NTP, it is good enough for us!
+ *
+ * In other words, by default, even if a clocksource is extremely
+ * precise (for example, with a sub-nanosecond period), the maximum
+ * permissible skew between the clocksource watchdog and the clocksource
+ * under test is not permitted to go below the 500ppm minimum defined
+ * by MAX_SKEW_USEC. This 500ppm minimum may be overridden using the
+ * CLOCKSOURCE_WATCHDOG_MAX_SKEW_US Kconfig option.
*/
#ifdef CONFIG_CLOCKSOURCE_WATCHDOG_MAX_SKEW_US
#define MAX_SKEW_USEC CONFIG_CLOCKSOURCE_WATCHDOG_MAX_SKEW_US
@@ -1146,14 +1153,19 @@ void __clocksource_update_freq_scale(struct clocksource *cs, u32 scale, u32 freq
}
/*
- * If the uncertainty margin is not specified, calculate it.
- * If both scale and freq are non-zero, calculate the clock
- * period, but bound below at 2*WATCHDOG_MAX_SKEW. However,
- * if either of scale or freq is zero, be very conservative and
- * take the tens-of-milliseconds WATCHDOG_THRESHOLD value for the
- * uncertainty margin. Allow stupidly small uncertainty margins
- * to be specified by the caller for testing purposes, but warn
- * to discourage production use of this capability.
+ * If the uncertainty margin is not specified, calculate it. If
+ * both scale and freq are non-zero, calculate the clock period, but
+ * bound below at 2*WATCHDOG_MAX_SKEW, that is, 500ppm by default.
+ * However, if either of scale or freq is zero, be very conservative
+ * and take the tens-of-milliseconds WATCHDOG_THRESHOLD value
+ * for the uncertainty margin. Allow stupidly small uncertainty
+ * margins to be specified by the caller for testing purposes,
+ * but warn to discourage production use of this capability.
+ *
+ * Bottom line: The sum of the uncertainty margins of the
+ * watchdog clocksource and the clocksource under test will be at
+ * least 500ppm by default. For more information, please see the
+ * comment preceding CONFIG_CLOCKSOURCE_WATCHDOG_MAX_SKEW_US above.
*/
if (scale && freq && !cs->uncertainty_margin) {
cs->uncertainty_margin = NSEC_PER_SEC / (scale * freq);
--
2.40.1
next prev parent reply other threads:[~2024-08-02 15:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <463c0174-356b-4918-8759-c36b1b30ba55@paulmck-laptop>
2024-08-02 15:45 ` [PATCH v2 clocksource 0/5] TSC and clocksource-watchdog updates for v6.12 Paul E. McKenney
2024-08-02 15:46 ` Paul E. McKenney [this message]
2024-08-02 16:43 ` [tip: timers/clocksource] clocksource: Improve comments for watchdog skew bounds tip-bot2 for Borislav Petkov
2024-08-02 15:46 ` [PATCH v2 TSC and clocksource-watchdog updates for v6.12 2/5] clocksource: Fix brown-bag boolean thinko in cs_watchdog_read() Paul E. McKenney
2024-08-02 16:34 ` [tip: timers/urgent] " tip-bot2 for Paul E. McKenney
2024-08-02 15:46 ` [PATCH v2 TSC and clocksource-watchdog updates for v6.12 3/5] clocksource: Fix comments on WATCHDOG_THRESHOLD & WATCHDOG_MAX_SKEW Paul E. McKenney
2024-08-02 16:43 ` [tip: timers/clocksource] " tip-bot2 for Paul E. McKenney
2024-08-02 15:46 ` [PATCH v2 TSC and clocksource-watchdog updates for v6.12 4/5] clocksource: Set cs_watchdog_read() checks based on .uncertainty_margin Paul E. McKenney
2024-08-02 16:43 ` [tip: timers/clocksource] " tip-bot2 for Paul E. McKenney
2024-08-02 15:46 ` [PATCH v2 TSC and clocksource-watchdog updates for v6.12 5/5] tsc: Check for sockets instead of CPUs to make code match comment Paul E. McKenney
2024-08-02 16:43 ` [tip: x86/timers] x86/tsc: " tip-bot2 for Paul E. McKenney
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=20240802154618.4149953-1-paulmck@kernel.org \
--to=paulmck@kernel.org \
--cc=Neeraj.Upadhyay@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=feng.tang@intel.com \
--cc=hpa@zytor.com \
--cc=jstultz@google.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@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®