* [PATCH v2 1/2] perf: tools: cs-etm: Fix print issue for Coresight debug in ETE/TRBE trace
@ 2026-03-18 10:36 Mike Leach
2026-03-18 10:36 ` [PATCH v2 2/2] perf: tools: cs-etm: Enhance raw Coresight trace debug display Mike Leach
2026-03-19 17:24 ` [PATCH v2 1/2] perf: tools: cs-etm: Fix print issue for Coresight debug in ETE/TRBE trace Namhyung Kim
0 siblings, 2 replies; 3+ messages in thread
From: Mike Leach @ 2026-03-18 10:36 UTC (permalink / raw)
To: linux-perf-users, linux-arm-kernel, coresight, linux-kernel, acme
Cc: suzuki.poulose, leo.yan, james.clark, peterz, mingo, will,
mark.rutland, alexander.shishkin, jolsa, namhyung, irogers,
Mike Leach
Building perf with CORESIGHT=1 and the optional CSTRACE_RAW=1 enables
additional debug printing of raw trace data when using command:-
perf report --dump.
This raw trace prints the CoreSight formatted trace frames, which may be
used to investigate suspected issues with trace quality / corruption /
decode.
These frames are not present in ETE + TRBE trace.
This fix removes the unnecessary call to print these frames.
This fix also rationalises implementation - original code had helper
function that unnecessarily repeated initialisation calls that had
already been made.
Due to an addtional fault with the OpenCSD library, this call when ETE/TRBE
are being decoded will cause a segfault in perf. This fix also prevents
that problem for perf using older (<= 1.8.0 version) OpenCSD libraries.
Fixes: 68ffe3902898 ("perf tools: Add decoder mechanic to support dumping trace data")
Reported-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Mike Leach <mike.leach@arm.com>
---
Changes in v2: Rationalise implementation
---
.../perf/util/cs-etm-decoder/cs-etm-decoder.c | 51 +++++--------------
1 file changed, 13 insertions(+), 38 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 3050fe212666..8592a778b26a 100644
--- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
+++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
@@ -237,46 +237,24 @@ cs_etm_decoder__init_def_logger_printing(struct cs_etm_decoder_params *d_params,
(void *)decoder,
cs_etm_decoder__print_str_cb);
if (ret != 0)
- ret = -1;
-
- return 0;
-}
+ return -1;
#ifdef CS_LOG_RAW_FRAMES
-static void
-cs_etm_decoder__init_raw_frame_logging(struct cs_etm_decoder_params *d_params,
- struct cs_etm_decoder *decoder)
-{
- /* Only log these during a --dump operation */
- if (d_params->operation == CS_ETM_OPERATION_PRINT) {
- /* set up a library default logger to process the
- * raw frame printer we add later
- */
- ocsd_def_errlog_init(OCSD_ERR_SEV_ERROR, 1);
-
- /* no stdout / err / file output */
- ocsd_def_errlog_config_output(C_API_MSGLOGOUT_FLG_NONE, NULL);
-
- /* set the string CB for the default logger,
- * passes strings to perf print logger.
- */
- ocsd_def_errlog_set_strprint_cb(decoder->dcd_tree,
- (void *)decoder,
- cs_etm_decoder__print_str_cb);
-
+ /*
+ * Only log raw frames if --dump operation and hardware is actually
+ * generating formatted CoreSight trace frames
+ */
+ if ((d_params->operation == CS_ETM_OPERATION_PRINT) &&
+ (d_params->formatted == true)) {
/* use the built in library printer for the raw frames */
- ocsd_dt_set_raw_frame_printer(decoder->dcd_tree,
- CS_RAW_DEBUG_FLAGS);
+ ret = ocsd_dt_set_raw_frame_printer(decoder->dcd_tree,
+ CS_RAW_DEBUG_FLAGS);
+ if (ret != 0)
+ return -1;
}
-}
-#else
-static void
-cs_etm_decoder__init_raw_frame_logging(
- struct cs_etm_decoder_params *d_params __maybe_unused,
- struct cs_etm_decoder *decoder __maybe_unused)
-{
-}
#endif
+ return 0;
+}
static ocsd_datapath_resp_t
cs_etm_decoder__do_soft_timestamp(struct cs_etm_queue *etmq,
@@ -738,9 +716,6 @@ cs_etm_decoder__new(int decoders, struct cs_etm_decoder_params *d_params,
if (ret != 0)
goto err_free_decoder;
- /* init raw frame logging if required */
- cs_etm_decoder__init_raw_frame_logging(d_params, decoder);
-
for (i = 0; i < decoders; i++) {
ret = cs_etm_decoder__create_etm_decoder(d_params,
&t_params[i],
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] perf: tools: cs-etm: Enhance raw Coresight trace debug display
2026-03-18 10:36 [PATCH v2 1/2] perf: tools: cs-etm: Fix print issue for Coresight debug in ETE/TRBE trace Mike Leach
@ 2026-03-18 10:36 ` Mike Leach
2026-03-19 17:24 ` [PATCH v2 1/2] perf: tools: cs-etm: Fix print issue for Coresight debug in ETE/TRBE trace Namhyung Kim
1 sibling, 0 replies; 3+ messages in thread
From: Mike Leach @ 2026-03-18 10:36 UTC (permalink / raw)
To: linux-perf-users, linux-arm-kernel, coresight, linux-kernel, acme
Cc: suzuki.poulose, leo.yan, james.clark, peterz, mingo, will,
mark.rutland, alexander.shishkin, jolsa, namhyung, irogers,
Mike Leach
When compiling perf with CORESIGHT=1, an additional build option may
be used: CSTRACE_RAW=1, which will cause the CoreSight formatted trace
frames to be printed out during a perf --dump command. This is useful
when investigating issues with trace generation, decode or possible
data corruption.
e.g. for ETMv4 trace source into a formatted ETR sink a dump -
. ... CoreSight ETMV4I Trace data: size 0x28c150 bytes
Idx:0; ID:14; I_ASYNC : Alignment Synchronisation.
Idx:12; ID:14; I_TRACE_INFO : Trace Info.; INFO=0x0 { CC.0 };
Decoder Sync point TINFO
Idx:17; ID:14; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.;
Addr=0x0000000000000000;
becomes with CSTRACE_RAW=1:
. ... CoreSight ETMV4I Trace data: size 0x28c150 bytes
Frame Data; Index 0; ID_DATA[0x14]; 00 00 00 00 00 00 00 00
00 00 00 80 01 01
Idx:0; ID:14; I_ASYNC : Alignment Synchronisation.
Frame Data; Index 16; ID_DATA[0x14]; 00 9d 00 00 00 00 00 00
00 00 04 85 57 08 f2
Idx:12; ID:14; I_TRACE_INFO : Trace Info.; INFO=0x0 { CC.0 };
Decoder Sync point TINFO
Idx:17; ID:14; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.;
Addr=0x0000000000000000;
CSTRACE_RAW=1 has no effect on ETE + TRBE trace as there is no trace
formatting in the TRBE buffer.
This patch enhances the output so that for each packet the individual
bytes associated with the packet are printed.
Thus for ETMv4 this now becomes:
. ... CoreSight ETMV4I Trace data: size 0x28c150 bytes
Frame Data; Index 0; ID_DATA[0x14]; 00 00 00 00 00 00 00 00
00 00 00 80 01 01
Idx:0; ID:14;[0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80];
I_ASYNC : Alignment Synchronisation.
Frame Data; Index 16; ID_DATA[0x14]; 00 9d 00 00 00 00 00 00
00 00 04 85 57 08 f2
Idx:12; ID:14; [0x01 0x01 0x00 ]; I_TRACE_INFO : Trace Info.; INFO=0x0
{ CC.0 }; Decoder Sync point TINFO
Idx:17; ID:14; [0x9d 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 ];
I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.;
Addr=0x0000000000000000;
ETE trace output changes from:
Idx:0; ID:14; I_ASYNC : Alignment Synchronisation.
Idx:12; ID:14; I_TRACE_INFO : Trace Info.; INFO=0x0 { CC.0, TSTATE.0 };
Decoder Sync point TINFO
Idx:15; ID:14; I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.;
Addr=0xFFFF80007CF7F56C;
becoming:
Idx:0; ID:14;[0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80];
I_ASYNC : Alignment Synchronisation.
Idx:12; ID:14; [0x01 0x01 0x00 ]; I_TRACE_INFO : Trace Info.; INFO=0x0
{ CC.0, TSTATE.0 }; Decoder Sync point TINFO
Idx:15; ID:14; [0x9d 0x5b 0x7a 0xf7 0x7c 0x00 0x80 0xff 0xff ];
I_ADDR_L_64IS0 : Address, Long, 64 bit, IS0.;
Addr=0xFFFF80007CF7F56C;
Tested-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Mike Leach <mike.leach@arm.com>
---
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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 8592a778b26a..91d3feb18aaf 100644
--- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
+++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c
@@ -22,12 +22,15 @@
/* use raw logging */
#ifdef CS_DEBUG_RAW
#define CS_LOG_RAW_FRAMES
+#define CS_PKT_MON 1
#ifdef CS_RAW_PACKED
#define CS_RAW_DEBUG_FLAGS (OCSD_DFRMTR_UNPACKED_RAW_OUT | \
OCSD_DFRMTR_PACKED_RAW_OUT)
#else
#define CS_RAW_DEBUG_FLAGS (OCSD_DFRMTR_UNPACKED_RAW_OUT)
#endif
+#else
+#define CS_PKT_MON 0
#endif
/*
@@ -664,7 +667,7 @@ cs_etm_decoder__create_etm_decoder(struct cs_etm_decoder_params *d_params,
trace_config, &csid))
return -1;
- if (ocsd_dt_set_pkt_protocol_printer(decoder->dcd_tree, csid, 0))
+ if (ocsd_dt_set_pkt_protocol_printer(decoder->dcd_tree, csid, CS_PKT_MON))
return -1;
return 0;
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/2] perf: tools: cs-etm: Fix print issue for Coresight debug in ETE/TRBE trace
2026-03-18 10:36 [PATCH v2 1/2] perf: tools: cs-etm: Fix print issue for Coresight debug in ETE/TRBE trace Mike Leach
2026-03-18 10:36 ` [PATCH v2 2/2] perf: tools: cs-etm: Enhance raw Coresight trace debug display Mike Leach
@ 2026-03-19 17:24 ` Namhyung Kim
1 sibling, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2026-03-19 17:24 UTC (permalink / raw)
To: linux-perf-users, linux-arm-kernel, coresight, linux-kernel,
acme, Mike Leach
Cc: suzuki.poulose, leo.yan, james.clark, peterz, mingo, will,
mark.rutland, alexander.shishkin, jolsa, irogers
On Wed, 18 Mar 2026 10:36:39 +0000, Mike Leach wrote:
> Building perf with CORESIGHT=1 and the optional CSTRACE_RAW=1 enables
> additional debug printing of raw trace data when using command:-
> perf report --dump.
>
> This raw trace prints the CoreSight formatted trace frames, which may be
> used to investigate suspected issues with trace quality / corruption /
> decode.
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-19 17:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-18 10:36 [PATCH v2 1/2] perf: tools: cs-etm: Fix print issue for Coresight debug in ETE/TRBE trace Mike Leach
2026-03-18 10:36 ` [PATCH v2 2/2] perf: tools: cs-etm: Enhance raw Coresight trace debug display Mike Leach
2026-03-19 17:24 ` [PATCH v2 1/2] perf: tools: cs-etm: Fix print issue for Coresight debug in ETE/TRBE trace Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®