History

clocksource: Scale the watchdog read retries automatically

On a 8-socket server the TSC is wrongly marked as 'unstable' and disabled during boot time on about one out of 120 boot attempts: clocksource: timekeeping watchdog on CPU227: wd-tsc-wd excessive read-back delay of 153560ns vs. limit of 125000ns, wd-wd read-back delay only 11440ns, attempt 3, marking tsc unstable tsc: Marking TSC unstable due to clocksource watchdog TSC found unstable after boot, most likely due to broken BIOS. Use 'tsc=unstable'. sched_clock: Marking unstable (119294969739, 159204297)<-(125446229205, -5992055152) clocksource: Checking clocksource tsc synchronization from CPU 319 to CPUs 0,99,136,180,210,542,601,896. clocksource: Switched to clocksource hpet The reason is that for platform with a large number of CPUs, there are sporadic big or huge read latencies while reading the watchog/clocksource during boot or when system is under stress work load, and the frequency and maximum value of the latency goes up with the number of online CPUs. The cCurrent code already has logic to detect and filter such high latency case by reading the watchdog twice and checking the two deltas. Due to the randomness of the latency, there is a low probabilty that the first delta (latency) is big, but the second delta is small and looks valid. The watchdog code retries the readouts by default twice, which is not necessarily sufficient for systems with a large number of CPUs. There is a command line parameter 'max_cswd_read_retries' which allows to increase the number of retries, but that's not user friendly as it needs to be tweaked per system. As the number of required retries is proportional to the number of online CPUs, this parameter can be calculated at runtime. Scale and enlarge the number of retries according to the number of online CPUs and remove the command line parameter completely. [ tglx: Massaged change log and comments ]

Feng Tang committed 2 years ago

Commit 2ed08e41 parent e0a12845 files · +25 −20Browse files

Showing the changes to include (1 of 5 files). Show all

Unified · Split

include/linux/clocksource.h+13−1
@@ -291,7 +291,19 @@ static inline void timer_probe(void) {} · 290 unmodified lines
291291 #define TIMER_ACPI_DECLARE(name, table_id, fn) \
292292 ACPI_DECLARE_PROBE_ENTRY(timer, name, table_id, 0, NULL, 0, fn)
293293
294−extern ulong max_cswd_read_retries;
294+static inline unsigned int clocksource_get_max_watchdog_retry(void)
295+{
296+ /*
297+ * When system is in the boot phase or under heavy workload, there
298+ * can be random big latencies during the clocksource/watchdog
299+ * read, so allow retries to filter the noise latency. As the
300+ * latency's frequency and maximum value goes up with the number of
301+ * CPUs, scale the number of retries with the number of online
302+ * CPUs.
303+ */
304+ return (ilog2(num_online_cpus()) / 2) + 1;
305+}
306+
295307 void clocksource_verify_percpu(struct clocksource *cs);
296308
297309 #endif /* _LINUX_CLOCKSOURCE_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t