diff options
| author | Dapeng Mi <dapeng1.mi@linux.intel.com> | 2025-09-19 10:16:57 +0800 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2025-10-02 15:31:14 -0300 |
| commit | 0f53264d714ae7db2a827b3483418f0288fa953f (patch) | |
| tree | 460bd6419b14aef7ce9147df25b834075efc1063 | |
| parent | 45ff39f6e70aa55d0054fbc3508eba9ac03d7e29 (diff) | |
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>
| -rw-r--r-- | tools/perf/util/env.c | 22 | ||||
| -rw-r--r-- | tools/perf/util/env.h | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index c8c248754621..f1626d2032cd 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -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; +} diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h index e00179787a34..9977b85523a8 100644 --- a/tools/perf/util/env.h +++ b/tools/perf/util/env.h @@ -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 */ |
