Hi
On Wed, 3 Apr 2019 at 11:31, Leo Yan leo.yan@linaro.org wrote:
On Wed, Mar 06, 2019 at 03:59:40PM -0700, Mathieu Poirier wrote:
Link contextID packets received from the decoder with the perf tool thread mechanic so that we know the specifics of the process currently executing.
Signed-off-by: Mathieu Poirier mathieu.poirier@linaro.org
.../perf/util/cs-etm-decoder/cs-etm-decoder.c | 20 ++++++++++++ tools/perf/util/cs-etm.c | 32 +++++++++++++++---- tools/perf/util/cs-etm.h | 10 ++++++ 3 files changed, 56 insertions(+), 6 deletions(-)
diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c index 87264b79de0e..ce85e52f989c 100644 --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c @@ -402,6 +402,24 @@ cs_etm_decoder__buffer_exception_ret(struct cs_etm_packet_queue *queue, CS_ETM_EXCEPTION_RET); }
+static ocsd_datapath_resp_t +cs_etm_decoder__set_tid(struct cs_etm_queue *etmq,
const ocsd_generic_trace_elem *elem,
const uint8_t trace_chan_id)
+{
pid_t tid;
/* Ignore PE_CONTEXT packets that don't have a valid contextID */
if (!elem->context.ctxt_id_valid)
return OCSD_RESP_CONT;
Just curious how to handle the case for trace discontinuity? If there have trace discontinuity, should we will receive a PE_CONTEXT packet at the beginning for the new trace block? Otherwise, it might be use the 'stale' context id before the discontinuity.
The ETM spec requires a context packet output after a discontinuity so this should be safe.
Mike
tid = elem->context.context_id;
if (cs_etm__etmq_set_tid(etmq, tid, trace_chan_id))
return OCSD_RESP_FATAL_SYS_ERR;
return OCSD_RESP_CONT;
+}
static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( const void *context, const ocsd_trc_index_t indx __maybe_unused, @@ -440,6 +458,8 @@ static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( trace_chan_id); break; case OCSD_GEN_TRC_ELEM_PE_CONTEXT:
resp = cs_etm_decoder__set_tid(etmq, elem, trace_chan_id);
break; case OCSD_GEN_TRC_ELEM_ADDR_NACC: case OCSD_GEN_TRC_ELEM_TIMESTAMP: case OCSD_GEN_TRC_ELEM_CYCLE_COUNT:
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index f696b8dd6e0a..e97124f218fd 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -906,13 +906,8 @@ cs_etm__get_trace(struct cs_etm_queue *etmq) }
static void cs_etm__set_pid_tid_cpu(struct cs_etm_auxtrace *etm,
struct auxtrace_queue *queue, struct cs_etm_traceid_queue *tidq)
{
/* CPU-wide tracing isn't supported yet */
if (queue->tid == -1)
return;
if ((!tidq->thread) && (tidq->tid != -1)) tidq->thread = machine__find_thread(etm->machine, -1, tidq->tid);
@@ -921,6 +916,31 @@ static void cs_etm__set_pid_tid_cpu(struct cs_etm_auxtrace *etm, tidq->pid = tidq->thread->pid_; }
+int cs_etm__etmq_set_tid(struct cs_etm_queue *etmq,
pid_t tid, u8 trace_chan_id)
+{
int cpu, err = -EINVAL;
struct cs_etm_auxtrace *etm = etmq->etm;
struct cs_etm_traceid_queue *tidq;
tidq = cs_etm__etmq_get_traceid_queue(etmq, trace_chan_id);
if (!tidq)
return err;
if (cs_etm__get_cpu(trace_chan_id, &cpu) < 0)
return err;
err = machine__set_current_tid(etm->machine, cpu, tid, tid);
if (err)
return err;
tidq->tid = tid;
thread__zput(tidq->thread);
cs_etm__set_pid_tid_cpu(etm, tidq);
return 0;
+}
static int cs_etm__synth_instruction_sample(struct cs_etm_queue *etmq, struct cs_etm_traceid_queue *tidq, u64 addr, u64 period) @@ -1869,7 +1889,7 @@ static int cs_etm__process_timeless_queues(struct cs_etm_auxtrace *etm, continue;
if ((tid == -1) || (tidq->tid == tid)) {
cs_etm__set_pid_tid_cpu(etm, queue, tidq);
cs_etm__set_pid_tid_cpu(etm, tidq); cs_etm__run_decoder(etmq); } }
diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h index 0dfc79a678f8..5f32b271a50e 100644 --- a/tools/perf/util/cs-etm.h +++ b/tools/perf/util/cs-etm.h @@ -182,6 +182,8 @@ struct cs_etm_packet_queue { int cs_etm__process_auxtrace_info(union perf_event *event, struct perf_session *session); int cs_etm__get_cpu(u8 trace_chan_id, int *cpu); +int cs_etm__etmq_set_tid(struct cs_etm_queue *etmq,
pid_t tid, u8 trace_chan_id);
struct cs_etm_packet_queue *cs_etm__etmq_get_packet_queue(struct cs_etm_queue *etmq, u8 trace_chan_id); #else @@ -198,6 +200,14 @@ static inline int cs_etm__get_cpu(u8 trace_chan_id __maybe_unused, return -1; }
+static inline int cs_etm__etmq_set_tid(
struct cs_etm_queue *etmq __maybe_unused,
pid_t tid __maybe_unused,
u8 trace_chan_id __maybe_unused)
+{
return -1;
+}
static inline struct cs_etm_packet_queue *cs_etm__etmq_get_packet_queue( struct cs_etm_queue *etmq __maybe_unused, u8 trace_chan_id __maybe_unused) -- 2.17.1
CoreSight mailing list CoreSight@lists.linaro.org https://lists.linaro.org/mailman/listinfo/coresight