[SRU][N:gke][PATCH 078/106] perf arm-spe: Introduce arm_spe__is_homogeneous()
Tim Whisonant
tim.whisonant at canonical.com
Mon Jul 21 16:22:01 UTC 2025
From: Leo Yan <leo.yan at arm.com>
BugLink: https://bugs.launchpad.net/bugs/2117098
Introduce the arm_spe__is_homogeneous() function, it uses to check if
Arm SPE is homogeneous cross all CPUs.
Signed-off-by: Leo Yan <leo.yan at arm.com>
Reviewed-by: James Clark <james.clark at linaro.org>
Link: https://lore.kernel.org/r/20241003185322.192357-4-leo.yan@arm.com
Signed-off-by: Namhyung Kim <namhyung at kernel.org>
(cherry picked from commit 56ae663e7636f2ce180201f0f18d7736c319a43f)
Signed-off-by: Tim Whisonant <tim.whisonant at canonical.com>
---
tools/perf/util/arm-spe.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/tools/perf/util/arm-spe.c b/tools/perf/util/arm-spe.c
index 29be702cd096b..5dd8dfc37e054 100644
--- a/tools/perf/util/arm-spe.c
+++ b/tools/perf/util/arm-spe.c
@@ -82,6 +82,7 @@ struct arm_spe {
u64 **metadata;
u64 metadata_ver;
u64 metadata_nr_cpu;
+ bool is_homogeneous;
};
struct arm_spe_queue {
@@ -1359,6 +1360,30 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session)
return 0;
}
+static bool arm_spe__is_homogeneous(u64 **metadata, int nr_cpu)
+{
+ u64 midr;
+ int i;
+
+ if (!nr_cpu)
+ return false;
+
+ for (i = 0; i < nr_cpu; i++) {
+ if (!metadata[i])
+ return false;
+
+ if (i == 0) {
+ midr = metadata[i][ARM_SPE_CPU_MIDR];
+ continue;
+ }
+
+ if (midr != metadata[i][ARM_SPE_CPU_MIDR])
+ return false;
+ }
+
+ return true;
+}
+
int arm_spe_process_auxtrace_info(union perf_event *event,
struct perf_session *session)
{
@@ -1404,6 +1429,7 @@ int arm_spe_process_auxtrace_info(union perf_event *event,
spe->metadata = metadata;
spe->metadata_ver = metadata_ver;
spe->metadata_nr_cpu = nr_cpu;
+ spe->is_homogeneous = arm_spe__is_homogeneous(metadata, nr_cpu);
spe->timeless_decoding = arm_spe__is_timeless_decoding(spe);
--
2.43.0
More information about the kernel-team
mailing list