summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-08-29 04:45:58 +0000
committerLuiz Souza <luiz@netgate.com>2017-05-09 16:01:02 -0500
commit346178ff8f7791e9c4d62ab019f681d4e24cef43 (patch)
tree02a6aff994efddf3470b334693c40bd914e09f2e
parent8e7913babb07928b594c165c9027dbb7cf2e3d82 (diff)
downloadFreeBSD-src-346178ff8f7791e9c4d62ab019f681d4e24cef43.zip
FreeBSD-src-346178ff8f7791e9c4d62ab019f681d4e24cef43.tar.gz
MFC r303548:
Cache getbintime(9) answer in timehands. (cherry picked from commit 5557ede983360bb766926977b87aff4d9272febb)
-rw-r--r--sys/kern/kern_tc.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index b313d98..4319123 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -68,6 +68,7 @@ struct timehands {
uint64_t th_scale;
u_int th_offset_count;
struct bintime th_offset;
+ struct bintime th_bintime;
struct timeval th_microtime;
struct timespec th_nanotime;
struct bintime th_boottime;
@@ -235,9 +236,8 @@ fbclock_bintime(struct bintime *bt)
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
- *bt = th->th_offset;
+ *bt = th->th_bintime;
bintime_addx(bt, th->th_scale * tc_delta(th));
- bintime_add(bt, &th->th_boottime);
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
}
@@ -311,8 +311,7 @@ fbclock_getbintime(struct bintime *bt)
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
- *bt = th->th_offset;
- bintime_add(bt, &th->th_boottime);
+ *bt = th->th_bintime;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
}
@@ -387,9 +386,8 @@ bintime(struct bintime *bt)
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
- *bt = th->th_offset;
+ *bt = th->th_bintime;
bintime_addx(bt, th->th_scale * tc_delta(th));
- bintime_add(bt, &th->th_boottime);
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
}
@@ -463,8 +461,7 @@ getbintime(struct bintime *bt)
do {
th = timehands;
gen = atomic_load_acq_int(&th->th_generation);
- *bt = th->th_offset;
- bintime_add(bt, &th->th_boottime);
+ *bt = th->th_bintime;
atomic_thread_fence_acq();
} while (gen == 0 || gen != th->th_generation);
}
@@ -1389,6 +1386,8 @@ tc_windup(struct bintime *new_boottimebin)
if (bt.sec != t)
th->th_boottime.sec += bt.sec - t;
}
+ th->th_bintime = th->th_offset;
+ bintime_add(&th->th_bintime, &th->th_boottime);
/* Update the UTC timestamps used by the get*() functions. */
/* XXX shouldn't do this here. Should force non-`get' versions. */
bintime2timeval(&bt, &th->th_microtime);
@@ -1808,9 +1807,8 @@ pps_event(struct pps_state *pps, int event)
/* Convert the count to a timespec. */
tcount = pps->capcount - pps->capth->th_offset_count;
tcount &= pps->capth->th_counter->tc_counter_mask;
- bt = pps->capth->th_offset;
+ bt = pps->capth->th_bintime;
bintime_addx(&bt, pps->capth->th_scale * tcount);
- bintime_add(&bt, &pps->capth->th_boottime);
bintime2timespec(&bt, &ts);
/* If the timecounter was wound up underneath us, bail out. */
OpenPOWER on IntegriCloud