]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf tests topology: Switch env->arch use to env->e_machine
authorIan Rogers <irogers@google.com>
Tue, 2 Jun 2026 15:24:59 +0000 (08:24 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 3 Jun 2026 19:45:04 +0000 (16:45 -0300)
Some arch string comparisons weren't normalized. Avoid potential
issues with normalized names vs uname values by swtiching to using the
e_machine.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Honglei Wang <jameshongleiwang@126.com>
Cc: Jan Polensky <japo@linux.ibm.com>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/topology.c

index f54502ebef4b61c24b8ce7a98a844450134d7921..bd7b859dea66a600b9e4780c27db7abecaf9d74d 100644 (file)
@@ -11,6 +11,7 @@
 #include "pmus.h"
 #include "target.h"
 #include <linux/err.h>
+#include "dwarf-regs.h"
 
 #define TEMPL "/tmp/perf-test-XXXXXX"
 #define DATA_SIZE      10
@@ -74,6 +75,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)
        struct aggr_cpu_id id;
        struct perf_cpu cpu;
        struct perf_env *env;
+       uint16_t e_machine;
 
        session = perf_session__new(&data, NULL);
        TEST_ASSERT_VAL("can't get session", !IS_ERR(session));
@@ -101,7 +103,9 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)
         *  condition is true (see do_core_id_test in header.c). So always
         *  run this test on those platforms.
         */
-       if (!env->cpu && strncmp(env->arch, "s390", 4) && strncmp(env->arch, "aarch64", 7))
+       e_machine = perf_env__e_machine(env, NULL);
+
+       if (!env->cpu && e_machine != EM_S390 && e_machine != EM_AARCH64)
                return TEST_SKIP;
 
        /*
@@ -110,7 +114,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)
         * physical_package_id will be set to -1. Hence skip this
         * test if physical_package_id returns -1 for cpu from perf_cpu_map.
         */
-       if (!strncmp(env->arch, "ppc64le", 7)) {
+       if (e_machine == EM_PPC64) {
                if (cpu__get_socket_id(perf_cpu_map__cpu(map, 0)) == -1)
                        return TEST_SKIP;
        }