Skip to content

Commit dd02926

Browse files
committed
clocksource: Improve "skew is too large" messages
When clocksource_watchdog() detects excessive clocksource skew compared to the watchdog clocksource, it marks the clocksource under test as unstable and prints several lines worth of message. But that message is unclear to anyone unfamiliar with the code: clocksource: timekeeping watchdog on CPU2: Marking clocksource 'wdtest-ktime' as unstable because the skew is too large: clocksource: 'kvm-clock' wd_nsec: 400744390 wd_now: 612625c2c wd_last: 5fa7f7c66 mask: ffffffffffffffff clocksource: 'wdtest-ktime' cs_nsec: 600744034 cs_now: 173081397a292d4f cs_last: 17308139565a8ced mask: ffffffffffffffff clocksource: 'kvm-clock' (not 'wdtest-ktime') is current clocksource. Therefore, add the following line near the end of that message: Clocksource 'wdtest-ktime' skewed 199999644 ns (199 ms) over watchdog 'kvm-clock' interval of 400744390 ns (400 ms) This new line clearly indicates the amount of skew between the two clocksources, along with the duration of the time interval over which the skew occurred, both in nanoseconds and milliseconds. Signed-off-by: Paul E. McKenney <[email protected]> Cc: John Stultz <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Stephen Boyd <[email protected]> Cc: Feng Tang <[email protected]>
1 parent f092eb3 commit dd02926

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernel/time/clocksource.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,20 @@ static void clocksource_watchdog(struct timer_list *unused)
446446
/* Check the deviation from the watchdog clocksource. */
447447
md = cs->uncertainty_margin + watchdog->uncertainty_margin;
448448
if (abs(cs_nsec - wd_nsec) > md) {
449+
u64 cs_wd_msec;
450+
u64 wd_msec;
451+
u32 wd_rem;
452+
449453
pr_warn("timekeeping watchdog on CPU%d: Marking clocksource '%s' as unstable because the skew is too large:\n",
450454
smp_processor_id(), cs->name);
451455
pr_warn(" '%s' wd_nsec: %lld wd_now: %llx wd_last: %llx mask: %llx\n",
452456
watchdog->name, wd_nsec, wdnow, wdlast, watchdog->mask);
453457
pr_warn(" '%s' cs_nsec: %lld cs_now: %llx cs_last: %llx mask: %llx\n",
454458
cs->name, cs_nsec, csnow, cslast, cs->mask);
459+
cs_wd_msec = div_u64_rem(cs_nsec - wd_nsec, 1000U * 1000U, &wd_rem);
460+
wd_msec = div_u64_rem(wd_nsec, 1000U * 1000U, &wd_rem);
461+
pr_warn(" Clocksource '%s' skewed %lld ns (%lld ms) over watchdog '%s' interval of %lld ns (%lld ms)\n",
462+
cs->name, cs_nsec - wd_nsec, cs_wd_msec, watchdog->name, wd_nsec, wd_msec);
455463
if (curr_clocksource == cs)
456464
pr_warn(" '%s' is current clocksource.\n", cs->name);
457465
else if (curr_clocksource)

0 commit comments

Comments
 (0)