git: 25bcd81b8d12 - main - armv6/legacy: optimize cpu_getcount performance

From: Wojciech Macek <wma_at_FreeBSD.org>
Date: Mon, 14 Mar 2022 06:52:29 UTC
The branch main has been updated by wma:

URL: https://cgit.FreeBSD.org/src/commit/?id=25bcd81b8d12468e28e438f58dd58e7c5ea8f8db

commit 25bcd81b8d12468e28e438f58dd58e7c5ea8f8db
Author:     Wojciech Macek <wma@FreeBSD.org>
AuthorDate: 2022-03-14 06:51:21 +0000
Commit:     Wojciech Macek <wma@FreeBSD.org>
CommitDate: 2022-03-14 06:51:21 +0000

    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 14e19581b819..86f16131f03f 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