summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/cpu.h
diff options
context:
space:
mode:
authorRay Kinsella <mdr@ashroe.eu>2021-11-26 14:57:35 +0000
committerDamjan Marion <dmarion@me.com>2022-01-27 20:01:45 +0000
commit0024e53ad048ff0a3cb34bd95679606c11a7154b (patch)
tree704f03a531a5742dce054bc8254c206deaa510cb /src/vppinfra/cpu.h
parentae0e3e748f04a1fb9ad2393533a164611c417103 (diff)
perfmon: prune bundles by available pmu counters
Prune perfmon bundles that exceed the number of available pmu counters. Type: improvement Signed-off-by: Ray Kinsella <mdr@ashroe.eu> Change-Id: I70fec26bb8ca915f4b980963e06c2e43dfde5a23
Diffstat (limited to 'src/vppinfra/cpu.h')
-rw-r--r--src/vppinfra/cpu.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/vppinfra/cpu.h b/src/vppinfra/cpu.h
index 50d8b61cab3..329e5cc298d 100644
--- a/src/vppinfra/cpu.h
+++ b/src/vppinfra/cpu.h
@@ -266,6 +266,24 @@ clib_cpu_march_priority_hsw ()
return -1;
}
+#define X86_CPU_ARCH_PERF_FUNC 0xA
+
+static inline int
+clib_get_pmu_counter_count (u8 *fixed, u8 *general)
+{
+#if defined(__x86_64__)
+ u32 __clib_unused eax = 0, ebx = 0, ecx = 0, edx = 0;
+ clib_get_cpuid (X86_CPU_ARCH_PERF_FUNC, &eax, &ebx, &ecx, &edx);
+
+ *general = (eax & 0xFF00) >> 8;
+ *fixed = (edx & 0xF);
+
+ return 1;
+#else
+ return 0;
+#endif
+}
+
static inline u32
clib_cpu_implementer ()
{