Skip to content

Commit c37e85c

Browse files
committed
clocksource: Loosen clocksource watchdog constraints
Currently, MAX_SKEW_USEC is set to 100 microseconds, which has worked reasonably well. However, NTP is willing to tolerate 500 microseconds of skew per second, and a clocksource that is good enough for NTP should be good enough for the clocksource watchdog. The watchdog's skew is controlled by MAX_SKEW_USEC and the CLOCKSOURCE_WATCHDOG_MAX_SKEW_US Kconfig option. However, these values are doubled before being associated with a clocksource's ->uncertainty_margin, and the ->uncertainty_margin values of the pair of clocksource's being compared are summed before checking against the skew. Therefore, set both MAX_SKEW_USEC and the default for the CLOCKSOURCE_WATCHDOG_MAX_SKEW_US Kconfig option to 125 microseconds of skew per second, resulting in 500 microseconds of skew per second in the clocksource watchdog's skew comparison. Suggested-by Rik van Riel <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent beaa1ff commit c37e85c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

kernel/time/Kconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,14 @@ config CLOCKSOURCE_WATCHDOG_MAX_SKEW_US
200200
int "Clocksource watchdog maximum allowable skew (in μs)"
201201
depends on CLOCKSOURCE_WATCHDOG
202202
range 50 1000
203-
default 100
203+
default 125
204204
help
205205
Specify the maximum amount of allowable watchdog skew in
206206
microseconds before reporting the clocksource to be unstable.
207+
The default is based on a half-second clocksource watchdog
208+
interval and NTP's maximum frequency drift of 500 parts
209+
per million. If the clocksource is good enough for NTP,
210+
it is good enough for the clocksource watchdog!
207211

208212
endmenu
209213
endif

kernel/time/clocksource.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ static char override_name[CS_NAME_LEN];
9595
static int finished_booting;
9696
static u64 suspend_start;
9797

98+
/*
99+
* Interval: 0.5sec.
100+
*/
101+
#define WATCHDOG_INTERVAL (HZ >> 1)
102+
98103
/*
99104
* Threshold: 0.0312s, when doubled: 0.0625s.
100105
* Also a default for cs->uncertainty_margin when registering clocks.
@@ -106,11 +111,14 @@ static u64 suspend_start;
106111
* clocksource surrounding a read of the clocksource being validated.
107112
* This delay could be due to SMIs, NMIs, or to VCPU preemptions. Used as
108113
* a lower bound for cs->uncertainty_margin values when registering clocks.
114+
*
115+
* The default of 500 parts per million is based on NTP's limits.
116+
* If a clocksource is good enough for NTP, it is good enough for us!
109117
*/
110118
#ifdef CONFIG_CLOCKSOURCE_WATCHDOG_MAX_SKEW_US
111119
#define MAX_SKEW_USEC CONFIG_CLOCKSOURCE_WATCHDOG_MAX_SKEW_US
112120
#else
113-
#define MAX_SKEW_USEC 100
121+
#define MAX_SKEW_USEC (125 * WATCHDOG_INTERVAL / HZ)
114122
#endif
115123

116124
#define WATCHDOG_MAX_SKEW (MAX_SKEW_USEC * NSEC_PER_USEC)
@@ -140,11 +148,6 @@ static inline void clocksource_watchdog_unlock(unsigned long *flags)
140148
static int clocksource_watchdog_kthread(void *data);
141149
static void __clocksource_change_rating(struct clocksource *cs, int rating);
142150

143-
/*
144-
* Interval: 0.5sec.
145-
*/
146-
#define WATCHDOG_INTERVAL (HZ >> 1)
147-
148151
static void clocksource_watchdog_work(struct work_struct *work)
149152
{
150153
/*

0 commit comments

Comments
 (0)