perf tool x86: Consolidate is_amd check into single function
[platform/kernel/linux-starfive.git] / tools / perf / arch / x86 / util / mem-events.c
index 32879d1..a8a782b 100644 (file)
@@ -5,6 +5,7 @@
 #include "map_symbol.h"
 #include "mem-events.h"
 #include "linux/string.h"
+#include "env.h"
 
 static char mem_loads_name[100];
 static bool mem_loads_name__init;
@@ -27,28 +28,12 @@ static struct perf_mem_event perf_mem_events_amd[PERF_MEM_EVENTS__MAX] = {
        E("mem-ldst",   "ibs_op//",     "ibs_op"),
 };
 
-static int perf_mem_is_amd_cpu(void)
-{
-       struct perf_env env = { .total_mem = 0, };
-
-       perf_env__cpuid(&env);
-       if (env.cpuid && strstarts(env.cpuid, "AuthenticAMD"))
-               return 1;
-       return -1;
-}
-
 struct perf_mem_event *perf_mem_events__ptr(int i)
 {
-       /* 0: Uninitialized, 1: Yes, -1: No */
-       static int is_amd;
-
        if (i >= PERF_MEM_EVENTS__MAX)
                return NULL;
 
-       if (!is_amd)
-               is_amd = perf_mem_is_amd_cpu();
-
-       if (is_amd == 1)
+       if (x86__is_amd_cpu())
                return &perf_mem_events_amd[i];
 
        return &perf_mem_events_intel[i];