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>
This commit is contained in:
Dapeng Mi 2025-09-19 10:16:57 +08:00 committed by Arnaldo Carvalho de Melo
parent 45ff39f6e7
commit 0f53264d71
2 changed files with 24 additions and 0 deletions

View File

@ -802,3 +802,25 @@ bool x86__is_amd_cpu(void)
return is_amd;
}
bool perf_env__is_x86_intel_cpu(struct perf_env *env)
{
static int is_intel; /* 0: Uninitialized, 1: Yes, -1: No */
if (is_intel == 0)
is_intel = env->cpuid && strstarts(env->cpuid, "GenuineIntel") ? 1 : -1;
return is_intel >= 1 ? true : false;
}
bool x86__is_intel_cpu(void)
{
struct perf_env env = { .total_mem = 0, };
bool is_intel;
perf_env__cpuid(&env);
is_intel = perf_env__is_x86_intel_cpu(&env);
perf_env__exit(&env);
return is_intel;
}

View File

@ -201,5 +201,7 @@ void perf_env__find_br_cntr_info(struct perf_env *env,
bool x86__is_amd_cpu(void);
bool perf_env__is_x86_amd_cpu(struct perf_env *env);
bool x86__is_intel_cpu(void);
bool perf_env__is_x86_intel_cpu(struct perf_env *env);
#endif /* __PERF_ENV_H */