From 25bcd81b8d12468e28e438f58dd58e7c5ea8f8db Mon Sep 17 00:00:00 2001 From: Wojciech Macek Date: Mon, 14 Mar 2022 07:51:21 +0100 Subject: [PATCH] armv6/legacy: optimize cpu_getcount performance Use nanotime instread of binuptime. This change is for old and legacy platforms and does not impact any armv7 and later. Might be MFCed to 13.0 once armv6 support is finally dropped in 14.0 Sponsored by: Stormshield Reviewed by: mw Obtained from: Semihalf Differential revision: https://reviews.freebsd.org/D33719 --- sys/arm/include/cpu.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/arm/include/cpu.h b/sys/arm/include/cpu.h index 14e19581b81..86f16131f03 100644 --- a/sys/arm/include/cpu.h +++ b/sys/arm/include/cpu.h @@ -40,11 +40,11 @@ get_cyclecount(void) } else #endif return cp15_pmccntr_get(); -#else /* No performance counters, so use binuptime(9). This is slooooow */ - struct bintime bt; +#else /* No performance counters, so use nanotime(9). */ + struct timespec tv; - binuptime(&bt); - return ((uint64_t)bt.sec << 56 | bt.frac >> 8); + nanotime(&tv); + return (tv.tv_sec * (uint64_t)1000000000ull + tv.tv_nsec); #endif } #endif