svn commit: r288473 - stable/10/sys/kern

Konstantin Belousov kib at FreeBSD.org
Fri Oct 2 05:27:13 UTC 2015


Author: kib
Date: Fri Oct  2 05:27:12 2015
New Revision: 288473
URL: https://svnweb.freebsd.org/changeset/base/288473

Log:
  MFC r288216:
  Use per-cpu values for base and last in tc_cpu_ticks().

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

Modified: stable/10/sys/kern/kern_tc.c
==============================================================================
--- stable/10/sys/kern/kern_tc.c	Fri Oct  2 05:04:17 2015	(r288472)
+++ stable/10/sys/kern/kern_tc.c	Fri Oct  2 05:27:12 2015	(r288473)
@@ -1888,20 +1888,27 @@ SYSINIT(timecounter, SI_SUB_CLOCKS, SI_O
 static int cpu_tick_variable;
 static uint64_t	cpu_tick_frequency;
 
+static DPCPU_DEFINE(uint64_t, tc_cpu_ticks_base);
+static DPCPU_DEFINE(unsigned, tc_cpu_ticks_last);
+
 static uint64_t
 tc_cpu_ticks(void)
 {
-	static uint64_t base;
-	static unsigned last;
-	unsigned u;
 	struct timecounter *tc;
+	uint64_t res, *base;
+	unsigned u, *last;
 
+	critical_enter();
+	base = DPCPU_PTR(tc_cpu_ticks_base);
+	last = DPCPU_PTR(tc_cpu_ticks_last);
 	tc = timehands->th_counter;
 	u = tc->tc_get_timecount(tc) & tc->tc_counter_mask;
-	if (u < last)
-		base += (uint64_t)tc->tc_counter_mask + 1;
-	last = u;
-	return (u + base);
+	if (u < *last)
+		*base += (uint64_t)tc->tc_counter_mask + 1;
+	*last = u;
+	res = u + *base;
+	critical_exit();
+	return (res);
 }
 
 void


More information about the svn-src-stable-10 mailing list