[PATCH v3 11/14] perf arm_spe: Improve CPU number retrieving in per-thread mode
Leo Yan
leo.yan at arm.com
Mon Jul 7 06:39:33 PDT 2025
In per-thread mode on a homogeneous system, the current code simply
picks the first metadata entry for data source parsing.
This change improves that by using the PMU type to find the matching PMU
event. From there, it reads the CPU map and uses the first CPU ID to
fetch the metadata.
Although this makes no difference when there's only one Arm SPE PMU, it
helps for future support of multiple SPE events.
Signed-off-by: Leo Yan <leo.yan at arm.com>
---
tools/perf/util/arm-spe.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index 3715afbe1e4713b5eebb00afbcb3eaa56ff1c49c..87cbba941d6f3066697ff430d6ce8e085b173032 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -914,6 +914,9 @@ static bool arm_spe__synth_ds(struct arm_spe_queue *speq,
union perf_mem_data_src *data_src)
{
struct arm_spe *spe = speq->spe;
+ struct perf_cpu_map *cpus;
+ struct perf_cpu perf_cpu;
+ int16_t cpu_nr;
u64 *metadata = NULL;
u64 midr;
unsigned int i;
@@ -935,13 +938,21 @@ static bool arm_spe__synth_ds(struct arm_spe_queue *speq,
if (!spe->is_homogeneous)
return false;
- /* In homogeneous system, simply use CPU0's metadata */
- if (spe->metadata)
- metadata = spe->metadata[0];
+ cpus = perf_pmus__find_by_type(spe->pmu_type)->cpus;
+ if (!cpus)
+ return false;
+
+ /* In a homogeneous system, fetch the first CPU in the map. */
+ perf_cpu = perf_cpu_map__cpu(cpus, 0);
+ if (perf_cpu.cpu == -1)
+ return false;
+
+ cpu_nr = perf_cpu.cpu;
} else {
- metadata = arm_spe__get_metadata_by_cpu(spe, speq->cpu);
+ cpu_nr = speq->cpu;
}
+ metadata = arm_spe__get_metadata_by_cpu(spe, cpu_nr);
if (!metadata)
return false;
--
2.34.1
More information about the linux-arm-kernel
mailing list