Module Name: src
Committed By: riastradh
Date: Tue Aug 1 19:36:57 UTC 2023
Modified Files:
src/sys/arch/x86/include: cpu.h
src/sys/arch/xen/xen: xen_clock.c
Log Message:
xen: Report when hardclock jump exceeds timecounter(9) limit.
To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/sys/arch/x86/include/cpu.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/xen/xen/xen_clock.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/x86/include/cpu.h
diff -u src/sys/arch/x86/include/cpu.h:1.135 src/sys/arch/x86/include/cpu.h:1.136
--- src/sys/arch/x86/include/cpu.h:1.135 Thu Jul 13 13:34:15 2023
+++ src/sys/arch/x86/include/cpu.h Tue Aug 1 19:36:57 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.135 2023/07/13 13:34:15 riastradh Exp $ */
+/* $NetBSD: cpu.h,v 1.136 2023/08/01 19:36:57 riastradh Exp $ */
/*
* Copyright (c) 1990 The Regents of the University of California.
@@ -326,6 +326,7 @@ struct cpu_info {
struct evcnt ci_xen_systime_backwards_hardclock_evcnt;
struct evcnt ci_xen_missed_hardclock_evcnt;
struct evcnt ci_xen_timecounter_backwards_evcnt;
+ struct evcnt ci_xen_timecounter_jump_evcnt;
#endif /* XEN */
#if defined(GPROF) && defined(MULTIPROCESSOR)
Index: src/sys/arch/xen/xen/xen_clock.c
diff -u src/sys/arch/xen/xen/xen_clock.c:1.15 src/sys/arch/xen/xen/xen_clock.c:1.16
--- src/sys/arch/xen/xen/xen_clock.c:1.15 Fri Jul 28 10:39:14 2023
+++ src/sys/arch/xen/xen/xen_clock.c Tue Aug 1 19:36:57 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: xen_clock.c,v 1.15 2023/07/28 10:39:14 riastradh Exp $ */
+/* $NetBSD: xen_clock.c,v 1.16 2023/08/01 19:36:57 riastradh Exp $ */
/*-
* Copyright (c) 2017, 2018 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
#endif
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xen_clock.c,v 1.15 2023/07/28 10:39:14 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xen_clock.c,v 1.16 2023/08/01 19:36:57 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -829,6 +829,24 @@ again:
if (__predict_false(delta >= 2*ns_per_tick)) {
SDT_PROBE3(sdt, xen, hardclock, jump,
last, now, delta/ns_per_tick);
+
+ /*
+ * Warn if we violate timecounter(9) contract: with a
+ * k-bit timeocunter (here k = 32), and timecounter
+ * frequency f (here f = 1 GHz), the maximum period
+ * between hardclock calls is 2^k / f. This comes out
+ * to 2^32 ns, in what is conveneintly already the
+ * correct unit for the Xen systime clock.
+ */
+ if (delta > xen_timecounter.tc_counter_mask) {
+ printf("WARNING: hardclock skipped %"PRIu64"ns"
+ " (%"PRIu64" -> %"PRIu64"),"
+ " exceeding maximum of %"PRIu32"ns"
+ " for timecounter(9)\n",
+ last, now, delta,
+ xen_timecounter.tc_counter_mask);
+ ci->ci_xen_timecounter_jump_evcnt.ev_count++;
+ }
}
while (delta >= ns_per_tick) {
ci->ci_xen_hardclock_systime_ns += ns_per_tick;