[PATCH v8 06/17] perf sample-raw: Use perf_env e_machine rather than arch

From: Ian Rogers

Date: Sat May 02 2026 - 03:01:04 EST


Use the e_machine rather than the arch to determine S390 and x86 types.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/sample-raw.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/sample-raw.c b/tools/perf/util/sample-raw.c
index bcf442574d6e..b10056ac8057 100644
--- a/tools/perf/util/sample-raw.c
+++ b/tools/perf/util/sample-raw.c
@@ -1,6 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0 */
-
-#include <string.h>
+#include <elf.h>
#include <linux/string.h>
#include "evlist.h"
#include "env.h"
@@ -14,14 +13,15 @@
*/
void evlist__init_trace_event_sample_raw(struct evlist *evlist, struct perf_env *env)
{
- const char *arch_pf = perf_env__arch(env);
- const char *cpuid = perf_env__cpuid(env);
+ uint16_t e_machine = perf_env__e_machine(env, /*e_eflags=*/NULL);

- if (arch_pf && !strcmp("s390", arch_pf))
+ if (e_machine == EM_S390) {
evlist->trace_event_sample_raw = evlist__s390_sample_raw;
- else if (arch_pf && !strcmp("x86", arch_pf) &&
- cpuid && strstarts(cpuid, "AuthenticAMD") &&
- evlist__has_amd_ibs(evlist)) {
- evlist->trace_event_sample_raw = evlist__amd_sample_raw;
+ } else if (e_machine == EM_X86_64 || e_machine == EM_386) {
+ const char *cpuid = perf_env__cpuid(env);
+
+ if (cpuid && strstarts(cpuid, "AuthenticAMD") &&
+ evlist__has_amd_ibs(evlist))
+ evlist->trace_event_sample_raw = evlist__amd_sample_raw;
}
}
--
2.54.0.545.g6539524ca2-goog