perf: cs-etm: Print queue number in raw trace dump
authorJames Clark <james.clark@arm.com>
Mon, 22 Jul 2024 10:11:49 +0000 (11:11 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 29 Aug 2024 18:56:37 +0000 (15:56 -0300)
Now that we have overlapping trace IDs it's also useful to know what the
queue number is to be able to distinguish the source of the trace so
print it inline. Hide it behind the -v option because it might not be
obvious to users what the queue number is.

Reviewed-by: Mike Leach <mike.leach@linaro.org>
Signed-off-by: James Clark <james.clark@arm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20240722101202.26915-8-james.clark@linaro.org
Signed-off-by: James Clark <james.clark@linaro.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
tools/perf/util/cs-etm-decoder/cs-etm-decoder.h
tools/perf/util/cs-etm.c

index d49c3e9c7c21f2274b12c1043da393a59b4c5619..b78ef0262135ca819052959c8bf72730a6efce01 100644 (file)
@@ -41,7 +41,7 @@ const u32 INSTR_PER_NS = 10;
 
 struct cs_etm_decoder {
        void *data;
-       void (*packet_printer)(const char *msg);
+       void (*packet_printer)(const char *msg, void *data);
        bool suppress_printing;
        dcd_tree_handle_t dcd_tree;
        cs_etm_mem_cb_type mem_access;
@@ -202,7 +202,7 @@ static void cs_etm_decoder__print_str_cb(const void *p_context,
        const struct cs_etm_decoder *decoder = p_context;
 
        if (p_context && str_len && !decoder->suppress_printing)
-               decoder->packet_printer(msg);
+               decoder->packet_printer(msg, decoder->data);
 }
 
 static int
index 272c2efe78eefc28ecacede67f70d87b0970848e..12c782fa6db285852f9f901735aa1f0e55b955e8 100644 (file)
@@ -60,7 +60,7 @@ struct cs_etm_trace_params {
 
 struct cs_etm_decoder_params {
        int operation;
-       void (*packet_printer)(const char *msg);
+       void (*packet_printer)(const char *msg, void *data);
        cs_etm_mem_cb_type mem_acc_cb;
        bool formatted;
        bool fsyncs;
index 775d4f35c270fc6b7f165833b16aa1d3a231ba8f..90f32f327b9b1f8265115939d383a9dabb6d0025 100644 (file)
@@ -762,15 +762,22 @@ static void cs_etm__packet_swap(struct cs_etm_auxtrace *etm,
        }
 }
 
-static void cs_etm__packet_dump(const char *pkt_string)
+static void cs_etm__packet_dump(const char *pkt_string, void *data)
 {
        const char *color = PERF_COLOR_BLUE;
        int len = strlen(pkt_string);
+       struct cs_etm_queue *etmq = data;
+       char queue_nr[64];
+
+       if (verbose)
+               snprintf(queue_nr, sizeof(queue_nr), "Qnr:%d; ", etmq->queue_nr);
+       else
+               queue_nr[0] = '\0';
 
        if (len && (pkt_string[len-1] == '\n'))
-               color_fprintf(stdout, color, "  %s", pkt_string);
+               color_fprintf(stdout, color, "  %s%s", queue_nr, pkt_string);
        else
-               color_fprintf(stdout, color, "  %s\n", pkt_string);
+               color_fprintf(stdout, color, "  %s%s\n", queue_nr, pkt_string);
 
        fflush(stdout);
 }