Make function cs_etm__dump_event() aware of CPU-wide trace scenarios and allocate the minimum amount of decoder required to handle the auxtrace buffers it is dealing with.
Signed-off-by: Mathieu Poirier mathieu.poirier@linaro.org --- tools/perf/util/cs-etm.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index f7c78c39266c..f75942acfdc3 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -182,10 +182,10 @@ static int cs_etm__init_decoder_params(struct cs_etm_decoder_params *d_params, return ret; }
-static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, +static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, int cpu, struct auxtrace_buffer *buffer) { - int ret; + int ret, num_cpu; const char *color = PERF_COLOR_BLUE; struct cs_etm_decoder_params d_params; struct cs_etm_trace_params *t_params; @@ -197,12 +197,20 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, ". ... CoreSight ETM Trace data: size %zu bytes\n", buffer->size);
+ /* + * If working on a per-thread scenario, each etmq needs to have + * a decoder capable of handling packets from all CPUs in the session. + * If working on CPU-wide scenario each etmq needs to deal with the + * CPU is has been assocated with. + */ + num_cpu = etm->timeless_decoding ? etm->num_cpu : 1; + /* Use metadata to fill in trace parameters for trace decoder */ - t_params = zalloc(sizeof(*t_params) * etm->num_cpu); + t_params = zalloc(sizeof(*t_params) * num_cpu); if (!t_params) return;
- if (cs_etm__init_trace_params(t_params, etm, -1, CS_ETM_PROTO_ETMV4i)) + if (cs_etm__init_trace_params(t_params, etm, cpu, CS_ETM_PROTO_ETMV4i)) return;
/* Set decoder parameters to simply print the trace packets */ @@ -210,7 +218,7 @@ static void cs_etm__dump_event(struct cs_etm_auxtrace *etm, CS_ETM_OPERATION_PRINT)) return;
- decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params); + decoder = cs_etm_decoder__new(num_cpu, &d_params, t_params);
zfree(&t_params);
@@ -1376,7 +1384,8 @@ static int cs_etm__process_auxtrace_event(struct perf_session *session,
if (dump_trace) if (auxtrace_buffer__get_data(buffer, fd)) { - cs_etm__dump_event(etm, buffer); + cs_etm__dump_event(etm, event->auxtrace.cpu, + buffer); auxtrace_buffer__put_data(buffer); } }