This was always an extra edge case to have to understand, and keeping it would require another new special case in the following change to add a timestamp decoder tree per trace ID. Removing it makes both cases simpler and nothing is really lost anyway. The only change needed is to seed every trace ID context with the TID from the AUX record, rather than only updating the single special context.
Signed-off-by: James Clark james.clark@linaro.org --- tools/perf/util/cs-etm.c | 34 ++++++++++++++-------------------- tools/perf/util/cs-etm.h | 10 ---------- 2 files changed, 14 insertions(+), 30 deletions(-)
diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 5c98c7960f82..accd4ffc19aa 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -51,13 +51,6 @@ struct cs_etm_auxtrace {
/* Trace timestamps are available and not disabled by --itrace=Z. */ bool has_timestamps; - - /* - * Per-thread ignores the trace channel ID and instead assumes that - * everything in a buffer comes from the same process regardless of - * which CPU it ran on. It also implies no context IDs so the TID is - * taken from the auxtrace buffer. - */ bool per_thread_decoding; bool snapshot_mode; bool has_virtual_ts; /* Trace timestamps can be used as kernel time. */ @@ -717,14 +710,8 @@ static struct cs_etm_traceid_queue { int idx; struct int_node *inode; - struct intlist *traceid_queues_list; + struct intlist *traceid_queues_list = etmq->traceid_queues_list; struct cs_etm_traceid_queue *tidq, **traceid_queues; - struct cs_etm_auxtrace *etm = etmq->etm; - - if (etm->per_thread_decoding) - trace_chan_id = CS_ETM_PER_THREAD_TRACEID; - - traceid_queues_list = etmq->traceid_queues_list;
/* * Check if the traceid_queue exist for this traceID by looking @@ -2225,15 +2212,22 @@ static int cs_etm__get_data_block(struct cs_etm_queue *etmq) /* * Per-thread mode still uses a queue for each CPU, but that CPU can run * different threads. When the TID from the AUX record on a CPU changes, - * re-initialize the thread using the AUX record/buffer fragment TID so - * we can start decoding even if the context ID packet was cropped or - * they're disabled. + * re-initialize the thread for each trace ID using the AUX record/buffer + * fragment TID so we can start decoding even if the context ID packet + * was cropped or they're disabled. */ if (etm->per_thread_decoding) { - struct cs_etm_traceid_queue *tidq = cs_etm__etmq_get_traceid_queue(etmq, - CS_ETM_PER_THREAD_TRACEID); + struct int_node *inode; + + intlist__for_each_entry(inode, etmq->traceid_list) { + struct cs_etm_traceid_queue *tidq; + + tidq = cs_etm__etmq_get_traceid_queue(etmq, inode->i); + if (!tidq) + return -ENOMEM; + if (thread__tid(tidq->decode_thread) == etmq->buffer->tid) + continue;
- if (thread__tid(tidq->decode_thread) != etmq->buffer->tid) { thread__zput(tidq->frontend_thread); thread__zput(tidq->decode_thread); tidq->frontend_thread = machine__findnew_thread( diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h index 71b1ef321625..ffe3a33885a7 100644 --- a/tools/perf/util/cs-etm.h +++ b/tools/perf/util/cs-etm.h @@ -195,16 +195,6 @@ struct cs_etm_packet {
#define CS_ETM_PACKET_MAX_BUFFER 1024
-/* - * When working with per-thread scenarios the process under trace can - * be scheduled on any CPU and as such, more than one traceID may be - * associated with the same process. Since a traceID of '0' is illegal - * as per the CoreSight architecture, use that specific value to - * identify the queue where all packets (with any traceID) are - * aggregated. - */ -#define CS_ETM_PER_THREAD_TRACEID 0 - struct cs_etm_packet_queue { u32 packet_count; u32 head;