From 6b8650e4ce386d79938f5a565f566b5a07c20384 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 13 Mar 2020 16:46:16 +0000 Subject: [PATCH] Using fallback when the (none)feature bit is present. --- src/aal/aal.h | 20 +++++++++++--------- src/aal/aal_arm.h | 14 +------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/aal/aal.h b/src/aal/aal.h index c1cbd02..9552c26 100644 --- a/src/aal/aal.h +++ b/src/aal/aal.h @@ -12,10 +12,6 @@ #if defined(__arm__) || defined(__aarch64__) # define PLATFORM_IS_ARM - /** - * on ARM cpu counters are accessible only in privileged mode - */ -# define SNMALLOC_NO_ALL_CPUCOUNTERS #endif namespace snmalloc @@ -31,6 +27,10 @@ namespace snmalloc * and so may use bit operations on pointer values. */ IntegerPointers = (1 << 0), + /** + * This architecture cannot access cpu cycles counters from userspace + */ + NoCpuCycleCounters = (1 << 1), }; /** @@ -68,12 +68,14 @@ namespace snmalloc */ static inline uint64_t tick() { -#if defined(SNMALLOC_NO_ALL_CPUCOUNTERS) - struct timespec n = {0, 0ul}; - clock_gettime(CLOCK_MONOTONIC, &n); + if constexpr((Arch::aal_features & NoCpuCycleCounters) == NoCpuCycleCounters) + { + struct timespec n = {0, 0ul}; + clock_gettime(CLOCK_MONOTONIC, &n); - return static_cast((n.tv_sec) * (1000000000 * n.tv_nsec)); -#elif __has_builtin(__builtin_readcyclecounter) && \ + return static_cast((n.tv_sec) * (1000000000 * n.tv_nsec)); + } +#if __has_builtin(__builtin_readcyclecounter) && \ !defined(SNMALLOC_NO_AAL_BUILTINS) return __builtin_readcyclecounter(); #else diff --git a/src/aal/aal_arm.h b/src/aal/aal_arm.h index 00964e4..73e79f9 100644 --- a/src/aal/aal_arm.h +++ b/src/aal/aal_arm.h @@ -18,7 +18,7 @@ namespace snmalloc /** * Bitmap of AalFeature flags */ - static constexpr uint64_t aal_features = IntegerPointers; + static constexpr uint64_t aal_features = IntegerPointers | NoCpuCycleCounters; /** * On pipelined processors, notify the core that we are in a spin loop and * that speculative execution past this point may not be a performance gain. @@ -27,18 +27,6 @@ namespace snmalloc { __asm__ volatile("yield"); } - - /** - * Issue a prefetch hint at the specified address. - */ - static inline void prefetch(void*) - { - } - - static inline uint64_t tick() - { - return 0ull; - } }; using AAL_Arch = AAL_arm;