[PATCH v8 07/17] perf sort: Use perf_env e_machine rather than arch
From: Ian Rogers
Date: Sat May 02 2026 - 03:01:02 EST
Use the e_machine rather than the arch to determine x86 or PPC types.
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/sort.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 0020089cb13c..06a641cf49e3 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <ctype.h>
+#include <elf.h>
#include <errno.h>
#include <inttypes.h>
#include <regex.h>
@@ -2673,9 +2674,10 @@ struct sort_dimension {
static int arch_support_sort_key(const char *sort_key, struct perf_env *env)
{
- const char *arch = perf_env__arch(env);
+ uint16_t e_machine = perf_env__e_machine(env, /*e_eflags=*/NULL);
- if (!strcmp("x86", arch) || !strcmp("powerpc", arch)) {
+ if (e_machine == EM_X86_64 || e_machine == EM_386 ||
+ e_machine == EM_PPC64 || e_machine == EM_PPC) {
if (!strcmp(sort_key, "p_stage_cyc"))
return 1;
if (!strcmp(sort_key, "local_p_stage_cyc"))
@@ -2686,14 +2688,14 @@ static int arch_support_sort_key(const char *sort_key, struct perf_env *env)
static const char *arch_perf_header_entry(const char *se_header, struct perf_env *env)
{
- const char *arch = perf_env__arch(env);
+ uint16_t e_machine = perf_env__e_machine(env, /*e_eflags=*/NULL);
- if (!strcmp("x86", arch)) {
+ if (e_machine == EM_X86_64 || e_machine == EM_386) {
if (!strcmp(se_header, "Local Pipeline Stage Cycle"))
return "Local Retire Latency";
else if (!strcmp(se_header, "Pipeline Stage Cycle"))
return "Retire Latency";
- } else if (!strcmp("powerpc", arch)) {
+ } else if (e_machine == EM_PPC64 || e_machine == EM_PPC) {
if (!strcmp(se_header, "Local INSTR Latency"))
return "Finish Cyc";
else if (!strcmp(se_header, "INSTR Latency"))
--
2.54.0.545.g6539524ca2-goog