Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Add helper x86__is_intel_cpu()

Add helper x86__is_intel_cpu() to indicate if it's a x86 intel platform.

Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Dapeng Mi and committed by
Arnaldo Carvalho de Melo
0f53264d 45ff39f6

+24
+22
tools/perf/util/env.c
··· 802 802 803 803 return is_amd; 804 804 } 805 + 806 + bool perf_env__is_x86_intel_cpu(struct perf_env *env) 807 + { 808 + static int is_intel; /* 0: Uninitialized, 1: Yes, -1: No */ 809 + 810 + if (is_intel == 0) 811 + is_intel = env->cpuid && strstarts(env->cpuid, "GenuineIntel") ? 1 : -1; 812 + 813 + return is_intel >= 1 ? true : false; 814 + } 815 + 816 + bool x86__is_intel_cpu(void) 817 + { 818 + struct perf_env env = { .total_mem = 0, }; 819 + bool is_intel; 820 + 821 + perf_env__cpuid(&env); 822 + is_intel = perf_env__is_x86_intel_cpu(&env); 823 + perf_env__exit(&env); 824 + 825 + return is_intel; 826 + }
+2
tools/perf/util/env.h
··· 201 201 202 202 bool x86__is_amd_cpu(void); 203 203 bool perf_env__is_x86_amd_cpu(struct perf_env *env); 204 + bool x86__is_intel_cpu(void); 205 + bool perf_env__is_x86_intel_cpu(struct perf_env *env); 204 206 205 207 #endif /* __PERF_ENV_H */