From a79ed6b1d1def38898a7bdc27c4bb5388947e1ea Mon Sep 17 00:00:00 2001 From: cheloha Date: Thu, 29 Feb 2024 00:18:48 +0000 Subject: [PATCH] dt(4): interval, profile: schedule clockintr relative to start of recording For the interval and profile providers, schedule the first clock interrupt to occur dp_nsecs nanoseconds after the start of recording. This makes the interval between the start of recording and the first event consistent across runs. With input from claudio@. Simplified by claudio@. Thread: https://marc.info/?l=openbsd-tech&m=170879058205043&w=2 ok mpi@ claudio@ --- sys/dev/dt/dt_dev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/dev/dt/dt_dev.c b/sys/dev/dt/dt_dev.c index e11122687eb..98b19792d82 100644 --- a/sys/dev/dt/dt_dev.c +++ b/sys/dev/dt/dt_dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dt_dev.c,v 1.31 2024/02/18 00:54:03 cheloha Exp $ */ +/* $OpenBSD: dt_dev.c,v 1.32 2024/02/29 00:18:48 cheloha Exp $ */ /* * Copyright (c) 2019 Martin Pieuchot @@ -477,6 +477,7 @@ dt_ioctl_get_stats(struct dt_softc *sc, struct dtioc_stat *dtst) int dt_ioctl_record_start(struct dt_softc *sc) { + uint64_t now; struct dt_pcb *dp; if (sc->ds_recording) @@ -487,6 +488,7 @@ dt_ioctl_record_start(struct dt_softc *sc) return ENOENT; rw_enter_write(&dt_lock); + now = nsecuptime(); TAILQ_FOREACH(dp, &sc->ds_pcbs, dp_snext) { struct dt_probe *dtp = dp->dp_dtp; @@ -497,7 +499,8 @@ dt_ioctl_record_start(struct dt_softc *sc) if (dp->dp_nsecs != 0) { clockintr_bind(&dp->dp_clockintr, dp->dp_cpu, dt_clock, dp); - clockintr_advance(&dp->dp_clockintr, dp->dp_nsecs); + clockintr_schedule(&dp->dp_clockintr, + now + dp->dp_nsecs); } } rw_exit_write(&dt_lock); -- 2.20.1