summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGanapatrao Kulkarni <gankulkarni@os.amperecomputing.com>2023-04-20 22:52:53 -0700
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-05-02 08:36:14 -0300
commit6bf86cada3eb8ec3eb80cdce5280e7a22dac8b01 (patch)
tree94c9cb8bfcff68ee91830e16dfdf66b5513115f8 /tools
parentd199226143f0ef6919131120319766ece514314e (diff)
downloadlinux-6bf86cada3eb8ec3eb80cdce5280e7a22dac8b01.tar.gz
linux-6bf86cada3eb8ec3eb80cdce5280e7a22dac8b01.tar.bz2
linux-6bf86cada3eb8ec3eb80cdce5280e7a22dac8b01.zip
perf cs-etm: Add fix for coresight trace for any range of CPUs
The current implementation supports coresight trace decode for a range of CPUs, if the first CPU is CPU0. Perf report segfaults, if tried for sparse CPUs list and also for any range of CPUs(non zero first CPU). Adding a fix to perf report for any range of CPUs and for sparse list. Signed-off-by: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com> Link: https://lore.kernel.org/r/20230421055253.83912-1-gankulkarni@os.amperecomputing.com Cc: suzuki.poulose@arm.com Cc: acme@kernel.org Cc: mathieu.poirier@linaro.org Cc: mike.leach@linaro.org Cc: linux-arm-kernel@lists.infradead.org Cc: darren@os.amperecomputing.com Cc: scclevenger@os.amperecomputing.com Cc: scott@os.amperecomputing.com Cc: linux-kernel@vger.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/cs-etm.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 456994564d6e..91299cc56bf7 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -291,6 +291,25 @@ static int cs_etm__metadata_set_trace_id(u8 trace_chan_id, u64 *cpu_metadata)
})
/*
+ * Get a metadata for a specific cpu from an array.
+ *
+ */
+static u64 *get_cpu_data(struct cs_etm_auxtrace *etm, int cpu)
+{
+ int i;
+ u64 *metadata = NULL;
+
+ for (i = 0; i < etm->num_cpu; i++) {
+ if (etm->metadata[i][CS_ETM_CPU] == (u64)cpu) {
+ metadata = etm->metadata[i];
+ break;
+ }
+ }
+
+ return metadata;
+}
+
+/*
* Handle the PERF_RECORD_AUX_OUTPUT_HW_ID event.
*
* The payload associates the Trace ID and the CPU.
@@ -359,8 +378,11 @@ static int cs_etm__process_aux_output_hw_id(struct perf_session *session,
return 0;
}
+ cpu_data = get_cpu_data(etm, cpu);
+ if (cpu_data == NULL)
+ return err;
+
/* not one we've seen before - lets map it */
- cpu_data = etm->metadata[cpu];
err = cs_etm__map_trace_id(trace_chan_id, cpu_data);
if (err)
return err;