Thread (10 messages) 10 messages, 3 authors, 2021-05-13

Re: [RFC PATCH] perf cs-etm: Handle valid-but-zero timestamps

From: James Clark <hidden>
Date: 2021-05-13 13:10:57
Also in: linux-arm-kernel, lkml

Possibly related (same subject, not in this thread)


On 12/05/2021 05:08, Leo Yan wrote:
On Tue, May 11, 2021 at 04:53:35PM +0300, James Clark wrote:

[...]
quoted
        /* First get the packet queue for this traceID */
        packet_queue = cs_etm__etmq_get_packet_queue(etmq, trace_chan_id);
@@ -320,7 +323,20 @@ cs_etm_decoder__do_hard_timestamp(struct cs_etm_queue *etmq,
         * which instructions started by subtracting the number of instructions
         * executed to the timestamp.
         */
-       packet_queue->timestamp = elem->timestamp - packet_queue->instr_count;
+       if (!elem->timestamp) {
+               packet_queue->timestamp = 0;
+               if (!warned_timestamp_zero) {
+                       pr_err("Zero Coresight timestamp found at Idx:%" OCSD_TRC_IDX_STR
+                               ". Decoding may be improved with --itrace=Z...\n", indx);
+                       warned_timestamp_zero = true;
+               }
+       }
+       else if (packet_queue->instr_count >= elem->timestamp) {
Nitpick: I personally think should use the condition ">" rather than ">=".
Yes, good catch. I actually changed this because I realised that
if they are equal it shouldn't print an error.
quoted
+               packet_queue->timestamp = 0;
+               pr_err("Timestamp calculation underflow at Idx:%" OCSD_TRC_IDX_STR "\n", indx);
+       }
+       else
+               packet_queue->timestamp = elem->timestamp - packet_queue->instr_count;
Nitpick for coding style, as described in
Documentation/process/coding-style.rst, section "3) Placing Braces and
Spaces", so here should use braces with the format:
Ok I will update and run it through checkpatch.pl before posting.

[...]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help