Skip to content

Commit 6bf86ca

Browse files
Ganapatrao Kulkarniacmel
authored andcommitted
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>
1 parent d199226 commit 6bf86ca

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tools/perf/util/cs-etm.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,25 @@ static int cs_etm__metadata_set_trace_id(u8 trace_chan_id, u64 *cpu_metadata)
290290
(typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask)); \
291291
})
292292

293+
/*
294+
* Get a metadata for a specific cpu from an array.
295+
*
296+
*/
297+
static u64 *get_cpu_data(struct cs_etm_auxtrace *etm, int cpu)
298+
{
299+
int i;
300+
u64 *metadata = NULL;
301+
302+
for (i = 0; i < etm->num_cpu; i++) {
303+
if (etm->metadata[i][CS_ETM_CPU] == (u64)cpu) {
304+
metadata = etm->metadata[i];
305+
break;
306+
}
307+
}
308+
309+
return metadata;
310+
}
311+
293312
/*
294313
* Handle the PERF_RECORD_AUX_OUTPUT_HW_ID event.
295314
*
@@ -359,8 +378,11 @@ static int cs_etm__process_aux_output_hw_id(struct perf_session *session,
359378
return 0;
360379
}
361380

381+
cpu_data = get_cpu_data(etm, cpu);
382+
if (cpu_data == NULL)
383+
return err;
384+
362385
/* not one we've seen before - lets map it */
363-
cpu_data = etm->metadata[cpu];
364386
err = cs_etm__map_trace_id(trace_chan_id, cpu_data);
365387
if (err)
366388
return err;

0 commit comments

Comments
 (0)