| From a182a86b806ea969cd929299e14a93d7c288cf77 Mon Sep 17 00:00:00 2001 |
| From: James Clark <james.clark@arm.com> |
| Date: Mon, 10 May 2021 17:32:47 +0300 |
| Subject: [PATCH] perf cs-etm: Refactor timestamp variable names |
| |
| Remove ambiguity in variable names relating to timestamps. |
| |
| A later commit will save the sample kernel timestamp in one of the etm |
| structs, so name all elements appropriately to avoid confusion. |
| |
| This is also removes some ambiguity arising from the fact that the |
| --timestamp argument to perf record refers to sample kernel timestamps, |
| and the /timestamp/ event modifier refers to CS timestamps, so the term |
| is overloaded. |
| |
| Signed-off-by: James Clark <james.clark@arm.com> |
| Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> |
| Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> |
| Cc: Al Grant <al.grant@arm.com> |
| Cc: Anshuman Khandual <anshuman.khandual@arm.com> |
| Cc: Branislav Rankov <branislav.rankov@arm.com> |
| Cc: Denis Nikitin <denik@chromium.org> |
| Cc: Jiri Olsa <jolsa@redhat.com> |
| Cc: John Garry <john.garry@huawei.com> |
| Cc: Leo Yan <leo.yan@linaro.org> |
| Cc: Mark Rutland <mark.rutland@arm.com> |
| Cc: Mike Leach <mike.leach@linaro.org> |
| Cc: Namhyung Kim <namhyung@kernel.org> |
| Cc: Suzuki Poulouse <suzuki.poulose@arm.com> |
| Cc: Will Deacon <will@kernel.org> |
| Cc: linux-arm-kernel@lists.infradead.org |
| Cc: coresight@lists.linaro.org |
| Link: https://lore.kernel.org/r/20210510143248.27423-2-james.clark@arm.com |
| Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> |
| --- |
| .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 18 ++++---- |
| tools/perf/util/cs-etm.c | 42 +++++++++---------- |
| tools/perf/util/cs-etm.h | 4 +- |
| 3 files changed, 31 insertions(+), 33 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 be94afff7ce2..1237364b742c 100644 |
| --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c |
| +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c |
| @@ -277,13 +277,13 @@ cs_etm_decoder__do_soft_timestamp(struct cs_etm_queue *etmq, |
| const uint8_t trace_chan_id) |
| { |
| /* No timestamp packet has been received, nothing to do */ |
| - if (!packet_queue->timestamp) |
| + if (!packet_queue->cs_timestamp) |
| return OCSD_RESP_CONT; |
| |
| - packet_queue->timestamp = packet_queue->next_timestamp; |
| + packet_queue->cs_timestamp = packet_queue->next_cs_timestamp; |
| |
| /* Estimate the timestamp for the next range packet */ |
| - packet_queue->next_timestamp += packet_queue->instr_count; |
| + packet_queue->next_cs_timestamp += packet_queue->instr_count; |
| packet_queue->instr_count = 0; |
| |
| /* Tell the front end which traceid_queue needs attention */ |
| @@ -309,8 +309,8 @@ cs_etm_decoder__do_hard_timestamp(struct cs_etm_queue *etmq, |
| * Function do_soft_timestamp() will report the value to the front end, |
| * hence asking the decoder to keep decoding rather than stopping. |
| */ |
| - if (packet_queue->timestamp) { |
| - packet_queue->next_timestamp = elem->timestamp; |
| + if (packet_queue->cs_timestamp) { |
| + packet_queue->next_cs_timestamp = elem->timestamp; |
| return OCSD_RESP_CONT; |
| } |
| |
| @@ -321,8 +321,8 @@ cs_etm_decoder__do_hard_timestamp(struct cs_etm_queue *etmq, |
| * which instructions started by substracting the number of instructions |
| * executed to the timestamp. |
| */ |
| - packet_queue->timestamp = elem->timestamp - packet_queue->instr_count; |
| - packet_queue->next_timestamp = elem->timestamp; |
| + packet_queue->cs_timestamp = elem->timestamp - packet_queue->instr_count; |
| + packet_queue->next_cs_timestamp = elem->timestamp; |
| packet_queue->instr_count = 0; |
| |
| /* Tell the front end which traceid_queue needs attention */ |
| @@ -335,8 +335,8 @@ cs_etm_decoder__do_hard_timestamp(struct cs_etm_queue *etmq, |
| static void |
| cs_etm_decoder__reset_timestamp(struct cs_etm_packet_queue *packet_queue) |
| { |
| - packet_queue->timestamp = 0; |
| - packet_queue->next_timestamp = 0; |
| + packet_queue->cs_timestamp = 0; |
| + packet_queue->next_cs_timestamp = 0; |
| packet_queue->instr_count = 0; |
| } |
| |
| diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c |
| index 592f30ebede0..c5e6a184d4c7 100644 |
| --- a/tools/perf/util/cs-etm.c |
| +++ b/tools/perf/util/cs-etm.c |
| @@ -34,8 +34,6 @@ |
| #include <tools/libc_compat.h> |
| #include "util.h" |
| |
| -#define MAX_TIMESTAMP (~0ULL) |
| - |
| struct cs_etm_auxtrace { |
| struct auxtrace auxtrace; |
| struct auxtrace_queues queues; |
| @@ -82,7 +80,7 @@ struct cs_etm_queue { |
| struct cs_etm_decoder *decoder; |
| struct auxtrace_buffer *buffer; |
| unsigned int queue_nr; |
| - u8 pending_timestamp; |
| + u8 pending_timestamp_chan_id; |
| u64 offset; |
| const unsigned char *buf; |
| size_t buf_len, buf_used; |
| @@ -201,7 +199,7 @@ void cs_etm__etmq_set_traceid_queue_timestamp(struct cs_etm_queue *etmq, |
| * be more than one channel per cs_etm_queue, we need to specify |
| * what traceID queue needs servicing. |
| */ |
| - etmq->pending_timestamp = trace_chan_id; |
| + etmq->pending_timestamp_chan_id = trace_chan_id; |
| } |
| |
| static u64 cs_etm__etmq_get_timestamp(struct cs_etm_queue *etmq, |
| @@ -209,22 +207,22 @@ static u64 cs_etm__etmq_get_timestamp(struct cs_etm_queue *etmq, |
| { |
| struct cs_etm_packet_queue *packet_queue; |
| |
| - if (!etmq->pending_timestamp) |
| + if (!etmq->pending_timestamp_chan_id) |
| return 0; |
| |
| if (trace_chan_id) |
| - *trace_chan_id = etmq->pending_timestamp; |
| + *trace_chan_id = etmq->pending_timestamp_chan_id; |
| |
| packet_queue = cs_etm__etmq_get_packet_queue(etmq, |
| - etmq->pending_timestamp); |
| + etmq->pending_timestamp_chan_id); |
| if (!packet_queue) |
| return 0; |
| |
| /* Acknowledge pending status */ |
| - etmq->pending_timestamp = 0; |
| + etmq->pending_timestamp_chan_id = 0; |
| |
| /* See function cs_etm_decoder__do_{hard|soft}_timestamp() */ |
| - return packet_queue->timestamp; |
| + return packet_queue->cs_timestamp; |
| } |
| |
| static void cs_etm__clear_packet_queue(struct cs_etm_packet_queue *queue) |
| @@ -797,7 +795,7 @@ static int cs_etm__setup_queue(struct cs_etm_auxtrace *etm, |
| int ret = 0; |
| unsigned int cs_queue_nr; |
| u8 trace_chan_id; |
| - u64 timestamp; |
| + u64 cs_timestamp; |
| struct cs_etm_queue *etmq = queue->priv; |
| |
| if (list_empty(&queue->head) || etmq) |
| @@ -837,7 +835,7 @@ static int cs_etm__setup_queue(struct cs_etm_auxtrace *etm, |
| |
| /* |
| * Run decoder on the trace block. The decoder will stop when |
| - * encountering a timestamp, a full packet queue or the end of |
| + * encountering a CS timestamp, a full packet queue or the end of |
| * trace for that block. |
| */ |
| ret = cs_etm__decode_data_block(etmq); |
| @@ -848,10 +846,10 @@ static int cs_etm__setup_queue(struct cs_etm_auxtrace *etm, |
| * Function cs_etm_decoder__do_{hard|soft}_timestamp() does all |
| * the timestamp calculation for us. |
| */ |
| - timestamp = cs_etm__etmq_get_timestamp(etmq, &trace_chan_id); |
| + cs_timestamp = cs_etm__etmq_get_timestamp(etmq, &trace_chan_id); |
| |
| /* We found a timestamp, no need to continue. */ |
| - if (timestamp) |
| + if (cs_timestamp) |
| break; |
| |
| /* |
| @@ -875,7 +873,7 @@ static int cs_etm__setup_queue(struct cs_etm_auxtrace *etm, |
| * queue and will be processed in cs_etm__process_queues(). |
| */ |
| cs_queue_nr = TO_CS_QUEUE_NR(queue_nr, trace_chan_id); |
| - ret = auxtrace_heap__add(&etm->heap, cs_queue_nr, timestamp); |
| + ret = auxtrace_heap__add(&etm->heap, cs_queue_nr, cs_timestamp); |
| out: |
| return ret; |
| } |
| @@ -2162,7 +2160,7 @@ static int cs_etm__process_queues(struct cs_etm_auxtrace *etm) |
| int ret = 0; |
| unsigned int cs_queue_nr, queue_nr; |
| u8 trace_chan_id; |
| - u64 timestamp; |
| + u64 cs_timestamp; |
| struct auxtrace_queue *queue; |
| struct cs_etm_queue *etmq; |
| struct cs_etm_traceid_queue *tidq; |
| @@ -2224,9 +2222,9 @@ refetch: |
| if (ret) |
| goto out; |
| |
| - timestamp = cs_etm__etmq_get_timestamp(etmq, &trace_chan_id); |
| + cs_timestamp = cs_etm__etmq_get_timestamp(etmq, &trace_chan_id); |
| |
| - if (!timestamp) { |
| + if (!cs_timestamp) { |
| /* |
| * Function cs_etm__decode_data_block() returns when |
| * there is no more traces to decode in the current |
| @@ -2249,7 +2247,7 @@ refetch: |
| * this queue/traceID. |
| */ |
| cs_queue_nr = TO_CS_QUEUE_NR(queue_nr, trace_chan_id); |
| - ret = auxtrace_heap__add(&etm->heap, cs_queue_nr, timestamp); |
| + ret = auxtrace_heap__add(&etm->heap, cs_queue_nr, cs_timestamp); |
| } |
| |
| out: |
| @@ -2321,7 +2319,7 @@ static int cs_etm__process_event(struct perf_session *session, |
| struct perf_tool *tool) |
| { |
| int err = 0; |
| - u64 timestamp; |
| + u64 sample_kernel_timestamp; |
| struct cs_etm_auxtrace *etm = container_of(session->auxtrace, |
| struct cs_etm_auxtrace, |
| auxtrace); |
| @@ -2335,11 +2333,11 @@ static int cs_etm__process_event(struct perf_session *session, |
| } |
| |
| if (sample->time && (sample->time != (u64) -1)) |
| - timestamp = sample->time; |
| + sample_kernel_timestamp = sample->time; |
| else |
| - timestamp = 0; |
| + sample_kernel_timestamp = 0; |
| |
| - if (timestamp || etm->timeless_decoding) { |
| + if (sample_kernel_timestamp || etm->timeless_decoding) { |
| err = cs_etm__update_queues(etm); |
| if (err) |
| return err; |
| diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h |
| index 3613043ffb47..726938cceed2 100644 |
| --- a/tools/perf/util/cs-etm.h |
| +++ b/tools/perf/util/cs-etm.h |
| @@ -172,8 +172,8 @@ struct cs_etm_packet_queue { |
| u32 head; |
| u32 tail; |
| u32 instr_count; |
| - u64 timestamp; |
| - u64 next_timestamp; |
| + u64 cs_timestamp; |
| + u64 next_cs_timestamp; |
| struct cs_etm_packet packet_buffer[CS_ETM_PACKET_MAX_BUFFER]; |
| }; |
| |
| -- |
| 2.31.0 |
| |