summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-11-12 11:50:01 +0100
committerDave Wallace <dwallacelf@gmail.com>2016-11-22 14:35:46 +0000
commitc0e939b34cef55fe8a99e1d26eb9010b735559c8 (patch)
tree40dec9fff4e463a3b999e252ecf91343b8eb931b
parent72c390917c1ab4b55d317e35e627166cbf1552cd (diff)
vppinfra: fix TSC clock detection on newer intel CPUs
Change-Id: Iff88c9a0dd1b7401605075221640b269bec12859 Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--vppinfra/vppinfra/cpu.h3
-rw-r--r--vppinfra/vppinfra/time.c4
2 files changed, 6 insertions, 1 deletions
diff --git a/vppinfra/vppinfra/cpu.h b/vppinfra/vppinfra/cpu.h
index a88eaa2d9ba..7d63f85b506 100644
--- a/vppinfra/vppinfra/cpu.h
+++ b/vppinfra/vppinfra/cpu.h
@@ -63,7 +63,8 @@ _ (avx, 1, ecx, 28) \
_ (avx2, 7, ebx, 5) \
_ (avx512f, 7, ebx, 16) \
_ (aes, 1, ecx, 25) \
-_ (sha, 7, ebx, 29)
+_ (sha, 7, ebx, 29) \
+_ (invariant_tsc, 0x80000007, edx, 8)
static inline int
clib_get_cpuid (const u32 lev, u32 * eax, u32 * ebx, u32 * ecx, u32 * edx)
diff --git a/vppinfra/vppinfra/time.c b/vppinfra/vppinfra/time.c
index e62ee8636ac..2bdb9da4b39 100644
--- a/vppinfra/vppinfra/time.c
+++ b/vppinfra/vppinfra/time.c
@@ -38,6 +38,7 @@
#include <vppinfra/os.h>
#include <vppinfra/time.h>
#include <vppinfra/format.h>
+#include <vppinfra/cpu.h>
#ifdef CLIB_UNIX
@@ -143,6 +144,9 @@ os_cpu_clock_frequency (void)
{
f64 cpu_freq;
+ if (clib_cpu_supports_invariant_tsc ())
+ return estimate_clock_frequency (1e-3);
+
/* First try /sys version. */
cpu_freq = clock_frequency_from_sys_filesystem ();
if (cpu_freq != 0)