perf arm_spe: Refactor arm_spe__get_metadata_by_cpu()

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>
This commit is contained in:
Leo Yan 2025-09-12 16:42:17 +01:00 committed by Arnaldo Carvalho de Melo
parent 786e7e7a50
commit 04abd5c065

View 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;