perf env: Add routine to read the env->cpuid from the running machine
[linux-2.6-microblaze.git] / tools / perf / util / env.c
index 3baca06..2a91a10 100644 (file)
@@ -2,6 +2,7 @@
 #include "cpumap.h"
 #include "debug.h"
 #include "env.h"
+#include "util/header.h"
 #include <linux/ctype.h>
 #include <linux/zalloc.h>
 #include "bpf-event.h"
@@ -256,6 +257,21 @@ int perf_env__read_cpu_topology_map(struct perf_env *env)
        return 0;
 }
 
+int perf_env__read_cpuid(struct perf_env *env)
+{
+       char cpuid[128];
+       int err = get_cpuid(cpuid, sizeof(cpuid));
+
+       if (err)
+               return err;
+
+       free(env->cpuid);
+       env->cpuid = strdup(cpuid);
+       if (env->cpuid == NULL)
+               return ENOMEM;
+       return 0;
+}
+
 static int perf_env__read_arch(struct perf_env *env)
 {
        struct utsname uts;