vppinfra: fix cpu freq init error if cpu support aperfmperf 77/40377/4
authorXiaoming Jiang <[email protected]>
Thu, 22 Feb 2024 13:24:20 +0000 (21:24 +0800)
committerFan Zhang <[email protected]>
Thu, 18 Jul 2024 08:46:14 +0000 (08:46 +0000)
After linux-v4.15, 'cpu MHz' in /proc/cpuinfo is CPU
real frequency on x86 if cpu support aperfmperf flags

more see linux commit:
https://github.com/torvalds/linux/commit/7d5905dc14a87805a59f3c5bf70173aac2bb18f8

Type: fix
Change-Id: Ib655a9a1c519104142120b343cd8ddbe0b6e50e6
Signed-off-by: Xiaoming Jiang <[email protected]>
src/vppinfra/cpu.h
src/vppinfra/time.c

index 7a1b75f..b3743d4 100644 (file)
@@ -150,6 +150,7 @@ _CLIB_MARCH_FN_REGISTRATION(fn)
   _ (movdir64b, 7, ecx, 28)                                                   \
   _ (enqcmd, 7, ecx, 29)                                                      \
   _ (avx512_fp16, 7, edx, 23)                                                 \
+  _ (aperfmperf, 0x00000006, ecx, 0)                                          \
   _ (invariant_tsc, 0x80000007, edx, 8)                                       \
   _ (monitorx, 0x80000001, ecx, 29)
 
index 5a6aaf1..f173649 100644 (file)
@@ -76,8 +76,11 @@ clock_frequency_from_proc_filesystem (void)
   f64 ppc_timebase = 0;                /* warnings be gone */
   unformat_input_t input;
 
-/* $$$$ aarch64 kernel doesn't report "cpu MHz" */
-#if defined(__aarch64__)
+#if defined(__x86_64__)
+  if (clib_cpu_supports_aperfmperf ())
+    return 0.0;
+#elif defined(__aarch64__)
+  /* $$$$ aarch64 kernel doesn't report "cpu MHz" */
   return 0.0;
 #endif