svn commit: r304974 - stable/11/sys/kern

Konstantin Belousov kib at FreeBSD.org
Mon Aug 29 04:46:00 UTC 2016


Author: kib
Date: Mon Aug 29 04:45:58 2016
New Revision: 304974
URL: https://svnweb.freebsd.org/changeset/base/304974

Log:
  MFC r303548:
  Cache getbintime(9) answer in timehands.

Modified:
  stable/11/sys/kern/kern_tc.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/kern_tc.c
==============================================================================
--- stable/11/sys/kern/kern_tc.c	Mon Aug 29 04:44:24 2016	(r304973)
+++ stable/11/sys/kern/kern_tc.c	Mon Aug 29 04:45:58 2016	(r304974)
@@ -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_boottimebi
 		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 eve
 	/* 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. */


More information about the svn-src-all mailing list