opnsense-src/sys/cddl/dev/dtrace
Mark Johnston 36ae5ce2f2 dtrace/arm64: Fix dtrace_gethrtime()
This routine returns a monotonic count of the number of nanoseconds elapsed
since the previous call.  On arm64 it uses the generic system timer.  The
implementation multiplies the counter value by 10**9 then divides by the counter
frequency, but this multiplication can overflow.  This can result in trace
records with non-monotonic timestamps, which breaks libdtrace's temporal
ordering algorithm.

An easy fix is to reverse the order of operations, since the counter frequency
will in general be smaller than 10**9.  (In fact, it's mandated to be 1Ghz in
ARMv9, which makes life simple.)  However, this can give a fair bit of error.
Adopt the calculation used on amd64, with tweaks to handle frequencies as low as
1MHz: the ARM generic timer documentation suggests that ARMv8 timers are
typically in the 1MHz-50MHz range, which is true on arm64 systems that I have
access to.

MFC after:	2 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D49244
2025-03-09 23:01:13 -04:00
..
aarch64 dtrace/arm64: Fix dtrace_gethrtime() 2025-03-09 23:01:13 -04:00
amd64 dtrace: Add some more annotations for KMSAN 2024-11-23 02:36:08 +00:00
arm dtrace: Avoid including dtrace_isa.c directly into dtrace.c 2024-07-24 17:24:46 -04:00
i386 dtrace: Avoid including dtrace_isa.c directly into dtrace.c 2024-07-24 17:24:46 -04:00
powerpc dtrace: Avoid including dtrace_isa.c directly into dtrace.c 2024-07-24 17:24:46 -04:00
riscv dtrace: Avoid including dtrace_isa.c directly into dtrace.c 2024-07-24 17:24:46 -04:00
x86 dtrace: Address KMSAN warnings in dtrace_disx86 2024-11-22 14:03:40 +00:00
dtrace_anon.c sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
dtrace_cddl.h sdt: Support fetching the probe sixth argument with MI machinery 2024-06-20 12:40:25 -04:00
dtrace_debug.c sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
dtrace_hacks.c sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
dtrace_ioctl.c dtrace: Avoid excessive pcpu allocations 2024-11-22 14:04:12 +00:00
dtrace_load.c dtrace: Avoid excessive pcpu allocations 2024-11-22 14:04:12 +00:00
dtrace_modevent.c sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
dtrace_sysctl.c sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
dtrace_test.c dtrace tests: Add a test case which validates FBT probe arguments 2024-09-19 09:22:03 +00:00
dtrace_unload.c sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
dtrace_vtime.c sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00