]> www.infradead.org Git - users/hch/misc.git/commitdiff
perf arm_spe: Refactor arm_spe__get_metadata_by_cpu()
authorLeo Yan <leo.yan@arm.com>
Fri, 12 Sep 2025 15:42:17 +0000 (16:42 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 19 Sep 2025 15:14:28 +0000 (12:14 -0300)
Handle "CPU=-1" (per-thread mode) in the arm_spe__get_metadata_by_cpu()
function. As a result, the function is more general and will be invoked
by a sequential change.

Reviewed-by: James Clark <james.clark@linaro.org>
Signed-off-by: Leo Yan <leo.yan@arm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ali Saidi <alisaidi@amazon.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/arm-spe.c

index c5fd62534e0362dd69c69f6e836cef6f67b0d060..58f80b5c0ab969448c962adb31abde5067cf4be3 100644 (file)
@@ -315,15 +315,28 @@ static int arm_spe_set_tid(struct arm_spe_queue *speq, pid_t tid)
        return 0;
 }
 
-static u64 *arm_spe__get_metadata_by_cpu(struct arm_spe *spe, u64 cpu)
+static u64 *arm_spe__get_metadata_by_cpu(struct arm_spe *spe, int cpu)
 {
        u64 i;
 
        if (!spe->metadata)
                return NULL;
 
+       /* CPU ID is -1 for per-thread mode */
+       if (cpu < 0) {
+               /*
+                * On the heterogeneous system, due to CPU ID is -1,
+                * cannot confirm the data source packet is supported.
+                */
+               if (!spe->is_homogeneous)
+                       return NULL;
+
+               /* In homogeneous system, simply use CPU0's metadata */
+               return spe->metadata[0];
+       }
+
        for (i = 0; i < spe->metadata_nr_cpu; i++)
-               if (spe->metadata[i][ARM_SPE_CPU] == cpu)
+               if (spe->metadata[i][ARM_SPE_CPU] == (u64)cpu)
                        return spe->metadata[i];
 
        return NULL;
@@ -915,22 +928,7 @@ static bool arm_spe__synth_ds(struct arm_spe_queue *speq,
                cpuid = perf_env__cpuid(perf_session__env(spe->session));
                midr = strtol(cpuid, NULL, 16);
        } else {
-               /* CPU ID is -1 for per-thread mode */
-               if (speq->cpu < 0) {
-                       /*
-                        * On the heterogeneous system, due to CPU ID is -1,
-                        * cannot confirm the data source packet is supported.
-                        */
-                       if (!spe->is_homogeneous)
-                               return false;
-
-                       /* In homogeneous system, simply use CPU0's metadata */
-                       if (spe->metadata)
-                               metadata = spe->metadata[0];
-               } else {
-                       metadata = arm_spe__get_metadata_by_cpu(spe, speq->cpu);
-               }
-
+               metadata = arm_spe__get_metadata_by_cpu(spe, speq->cpu);
                if (!metadata)
                        return false;