All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Clocksource: Avoid misjudgment of clocksource
@ 2021-10-08  8:03 yanghui
  2021-10-08 23:45 ` John Stultz
  0 siblings, 1 reply; 29+ messages in thread
From: yanghui @ 2021-10-08  8:03 UTC (permalink / raw)
  To: John.stultz; +Cc: tglx, sboyd, linux-kernel, yanghui

clocksource_watchdog is executed every WATCHDOG_INTERVAL(0.5s) by
Timer. But sometimes system is very busy and the Timer cannot be
executed in 0.5sec. For example,if clocksource_watchdog be executed
after 10sec, the calculated value of abs(cs_nsec - wd_nsec) will
be enlarged. Then the current clocksource will be misjudged as
unstable. So we add conditions to prevent the clocksource from
being misjudged.

Signed-off-by: yanghui <yanghui.def@bytedance.com>
---
 kernel/time/clocksource.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index b8a14d2fb5ba..d535beadcbc8 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -136,8 +136,10 @@ static void __clocksource_change_rating(struct clocksource *cs, int rating);
 
 /*
  * Interval: 0.5sec.
+ * MaxInterval: 1s.
  */
 #define WATCHDOG_INTERVAL (HZ >> 1)
+#define WATCHDOG_MAX_INTERVAL_NS (NSEC_PER_SEC)
 
 static void clocksource_watchdog_work(struct work_struct *work)
 {
@@ -404,7 +406,9 @@ static void clocksource_watchdog(struct timer_list *unused)
 
 		/* Check the deviation from the watchdog clocksource. */
 		md = cs->uncertainty_margin + watchdog->uncertainty_margin;
-		if (abs(cs_nsec - wd_nsec) > md) {
+		if ((abs(cs_nsec - wd_nsec) > md) &&
+			cs_nsec < WATCHDOG_MAX_INTERVAL_NS &&
+			wd_nsec < WATCHDOG_MAX_INTERVAL_NS) {
 			pr_warn("timekeeping watchdog on CPU%d: Marking clocksource '%s' as unstable because the skew is too large:\n",
 				smp_processor_id(), cs->name);
 			pr_warn("                      '%s' wd_nsec: %lld wd_now: %llx wd_last: %llx mask: %llx\n",
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2021-12-09 16:44 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-08  8:03 [PATCH] Clocksource: Avoid misjudgment of clocksource yanghui
2021-10-08 23:45 ` John Stultz
2021-10-09  3:22   ` [External] " yanghui
2021-10-09  3:38     ` John Stultz
2021-10-09  9:02       ` yanghui
2021-10-12  5:02         ` John Stultz
2021-10-18 10:41           ` yanghui
2021-10-09 14:04   ` brookxu
2021-10-12  4:52     ` John Stultz
2021-10-12  5:21       ` brookxu
2021-10-12  5:29         ` John Stultz
2021-10-12  8:06           ` brookxu
2021-10-14  7:03             ` yanghui
2021-10-15  6:56               ` yanghui
2021-10-15  7:24                 ` brookxu
2021-10-18 16:14             ` John Stultz
2021-10-19  4:14               ` yanghui
2021-10-19  5:00                 ` John Stultz
2021-10-20 10:09                   ` Luming Yu
2021-10-20 17:49                     ` Paul E. McKenney
2021-10-21  9:37                       ` Luming Yu
2021-10-22 23:36                         ` Paul E. McKenney
2021-11-01  9:59                           ` Luming Yu
2021-11-01 16:57                             ` Paul E. McKenney
2021-11-03  8:27                               ` Luming Yu
2021-11-03 15:54                                 ` Paul E. McKenney
2021-11-04 10:56                                   ` Luming Yu
2021-12-09 13:14   ` Gang Li
2021-12-09 16:44     ` Paul E. McKenney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.