diff options
author | avg <avg@FreeBSD.org> | 2011-05-16 15:29:59 +0000 |
---|---|---|
committer | avg <avg@FreeBSD.org> | 2011-05-16 15:29:59 +0000 |
commit | 576b51ab8f786d77da023fb2e83fdc1fb0c7abf6 (patch) | |
tree | b2c4b470c3bfa995c74975f76d90d27867ff83a4 /sys/cddl/dev/cyclic/cyclic.c | |
parent | 90fe5b5b3e46a2da849cf8d0bba00f4834d39398 (diff) | |
download | FreeBSD-src-576b51ab8f786d77da023fb2e83fdc1fb0c7abf6.zip FreeBSD-src-576b51ab8f786d77da023fb2e83fdc1fb0c7abf6.tar.gz |
better integrate cyclic module with clocksource/eventtimer subsystem
Now in the case when one-shot timers are used cyclic events should fire
closer to theier scheduled times. As the cyclic is currently used only
to drive DTrace profile provider, this is the area where the change
makes a difference.
Reviewed by: mav (earlier version, a while ago)
X-MFC after: clocksource/eventtimer subsystem
Diffstat (limited to 'sys/cddl/dev/cyclic/cyclic.c')
-rw-r--r-- | sys/cddl/dev/cyclic/cyclic.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/cddl/dev/cyclic/cyclic.c b/sys/cddl/dev/cyclic/cyclic.c index b9a6979..e7b7f50 100644 --- a/sys/cddl/dev/cyclic/cyclic.c +++ b/sys/cddl/dev/cyclic/cyclic.c @@ -341,6 +341,16 @@ static cyc_backend_t cyclic_backend; MALLOC_DEFINE(M_CYCLIC, "cyclic", "Cyclic timer subsystem"); +static __inline hrtime_t +cyc_gethrtime(void) +{ + struct bintime bt; + + binuptime(&bt); + return ((hrtime_t)bt.sec * NANOSEC + + (((uint64_t)NANOSEC * (uint32_t)(bt.frac >> 32)) >> 32)); +} + /* * Returns 1 if the upheap propagated to the root, 0 if it did not. This * allows the caller to reprogram the backend only when the root has been @@ -507,7 +517,7 @@ cyclic_fire(cpu_t *c) cyc_index_t *heap = cpu->cyp_heap; cyclic_t *cyclic, *cyclics = cpu->cyp_cyclics; void *arg = be->cyb_arg; - hrtime_t now = gethrtime(); + hrtime_t now = cyc_gethrtime(); hrtime_t exp; if (cpu->cyp_nelems == 0) { @@ -687,7 +697,7 @@ cyclic_add_xcall(cyc_xcallarg_t *arg) * If a start time hasn't been explicitly specified, we'll * start on the next interval boundary. */ - cyclic->cy_expire = (gethrtime() / cyclic->cy_interval + 1) * + cyclic->cy_expire = (cyc_gethrtime() / cyclic->cy_interval + 1) * cyclic->cy_interval; } else { cyclic->cy_expire = when->cyt_when; |