[PATCH 07/19] coresight: trbe: Refactor AUX flag setting
James Clark
james.clark at linaro.org
Tue Dec 9 05:37:39 PST 2025
On 01/12/2025 11:21 am, Leo Yan wrote:
> Rather than spreading AUX flag setting in different functions, use
> trbe_get_fault_act() as a central place for setting the flag.
>
> Later we will support WRAP mode with continuous trace, so the WRAP
> event does not necessarily cause the trace discontinuity, change to
> check the stop status instead.
>
> Signed-off-by: Leo Yan <leo.yan at arm.com>
> ---
> drivers/hwtracing/coresight/coresight-trbe.c | 38 +++++++++++++---------------
> 1 file changed, 17 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
> index 28e2bfa68074f19ccaa4a737d00af577aea818fe..b06885a08e082fd34f68d9588518807b5c47c86e 100644
> --- a/drivers/hwtracing/coresight/coresight-trbe.c
> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
> @@ -265,25 +265,6 @@ static void trbe_reset_local(struct trbe_cpudata *cpudata)
> write_sysreg_s(0, SYS_TRBSR_EL1);
> }
>
> -static void trbe_report_wrap_event(struct perf_output_handle *handle)
> -{
> - /*
> - * Mark the buffer to indicate that there was a WRAP event by
> - * setting the COLLISION flag. This indicates to the user that
> - * the TRBE trace collection was stopped without stopping the
> - * ETE and thus there might be some amount of trace that was
> - * lost between the time the WRAP was detected and the IRQ
> - * was consumed by the CPU.
> - *
> - * Setting the TRUNCATED flag would move the event to STOPPED
> - * state unnecessarily, even when there is space left in the
> - * ring buffer. Using the COLLISION flag doesn't have this side
> - * effect. We only set TRUNCATED flag when there is no space
> - * left in the ring buffer.
> - */
> - perf_aux_output_flag(handle, PERF_AUX_FLAG_COLLISION);
> -}
> -
> static void trbe_truncate_event(struct perf_output_handle *handle)
> {
> struct trbe_buf *buf = etm_perf_sink_config(handle);
> @@ -687,6 +668,23 @@ static enum trbe_fault_action trbe_get_fault_act(struct perf_output_handle *hand
> goto out_fatal;
> }
>
> + /*
> + * Mark the buffer to indicate that there was a WRAP event by
> + * setting the COLLISION flag. This indicates to the user that
> + * the TRBE trace collection was stopped without stopping the
> + * ETE and thus there might be some amount of trace that was
> + * lost between the time the WRAP was detected and the IRQ
> + * was consumed by the CPU.
> + *
> + * Setting the TRUNCATED flag would move the event to STOPPED
> + * state unnecessarily, even when there is space left in the
> + * ring buffer. Using the COLLISION flag doesn't have this side
> + * effect. We only set TRUNCATED flag when there is no space
> + * left in the ring buffer.
> + */
> + if (!is_trbe_running(trbsr))
> + perf_aux_output_flag(handle, PERF_AUX_FLAG_COLLISION);
> +
Do we need the complexity of COLLISION (changed to PARTIAL in a later
commit) and TRUNCATED at the same time?
From my understanding, TRUNCATED would be when Perf is too slow and we
want to disable the event for it to catch up, and PARTIAL is when there
was some buffer error so technically we don't need the event to be
disabled, but Perf still needs to be notified if we want to start only
resetting the decoder when a flag is set rather than on all aux records?
There is no happy path where there is a buffer error, so I'm not sure
why we need the complexity of an extra case? There's no harm in
disabling the event on a buffer error. Also it's hard to see what the
exact scenario for PARTIAL is, because we set truncated anyway for fatal
statuses. The comment in the later commit for the PARTIAL change just
says "trace was stopped", but not why.
> if (is_trbe_wrap(trbsr))
> return TRBE_FAULT_ACT_WRAP;
>
> @@ -878,7 +876,6 @@ static unsigned long arm_trbe_update_buffer(struct coresight_device *csdev,
> goto done;
> }
>
> - trbe_report_wrap_event(handle);
> wrap = true;
> }
>
> @@ -1099,7 +1096,6 @@ static int trbe_handle_overflow(struct perf_output_handle *handle)
> if (buf->snapshot)
> handle->head += size;
>
> - trbe_report_wrap_event(handle);
> perf_aux_output_end(handle, size);
> event_data = perf_aux_output_begin(handle, event);
> if (!event_data) {
>
More information about the linux-arm-kernel
mailing list