diff options
author | kib <kib@FreeBSD.org> | 2015-10-02 05:27:12 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2015-10-02 05:27:12 +0000 |
commit | ce6871d5482c4e81e6fe27a37d958407993e7b67 (patch) | |
tree | d64b9058c2bd3783726ab933d89ee3e60d4d9e32 /sys/kern/kern_tc.c | |
parent | 09cf7d031eec32693605affb325dc8be38b0961a (diff) | |
download | FreeBSD-src-ce6871d5482c4e81e6fe27a37d958407993e7b67.zip FreeBSD-src-ce6871d5482c4e81e6fe27a37d958407993e7b67.tar.gz |
MFC r288216:
Use per-cpu values for base and last in tc_cpu_ticks().
Diffstat (limited to 'sys/kern/kern_tc.c')
-rw-r--r-- | sys/kern/kern_tc.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 08b4f66..e9240ce 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -1888,20 +1888,27 @@ SYSINIT(timecounter, SI_SUB_CLOCKS, SI_ORDER_SECOND, inittimecounter, NULL); 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 |