[PATCH 07/25] coresight: perf: Validate the live context through its path
James Clark
james.clark at linaro.org
Mon Oct 19 02:25:26 PDT 2026
On 15/09/2026 16:48, Leo Yan wrote:
> etm_event_get_ctxt_path() returns a path only when the per-CPU
> context has published event data and that data contains a path for the
> current CPU. Perf PMU callbacks run on the same CPU in atomic context,
> and only the normal stop clears the event data. A returned path therefore
> establishes that the pause and stop callbacks have a live ETM context.
>
> The AUX handle has a separate lifetime. It can be absent after an AUX
> transaction could not be restarted while the CoreSight path still needs
> to be paused or disabled. The handle is acquired for the callback event
> before event data is published, and another ETM event cannot replace it
> while the published context remains live. Thus any active handle belongs
> to that context, and etm_event_update_buffer() uses perf_get_aux() to
> determine whether it remains valid.
>
> Remove the redundant comparisons of the handle with the event and event
> data, together with the redundant event_data check. Use the path to
> validate the ETM context lifetime and perf_get_aux() to validate the AUX
> handle lifetime.
>
> Assisted-by: Codex:gpt-6
> Signed-off-by: Leo Yan <leo.yan at arm.com>
> ---
> drivers/hwtracing/coresight/coresight-etm-perf.c | 15 ---------------
> 1 file changed, 15 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
> index afd22fd4a851e600ab69fd5b6883e6f8518b2cab..c7454da5c881c4a8eea5cc77902c9113c297096e 100644
> --- a/drivers/hwtracing/coresight/coresight-etm-perf.c
> +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
> @@ -698,9 +698,6 @@ static void etm_event_pause(struct coresight_path *path,
> if (coresight_is_percpu_sink(sink))
> return;
>
> - if (WARN_ON_ONCE(handle->event != event))
> - return;
> -
> event_data = READ_ONCE(ctxt->event_data);
> etm_event_update_buffer(handle, event_data, sink, PERF_EF_UPDATE);
>
> @@ -728,14 +725,6 @@ static void etm_event_stop(struct perf_event *event, int mode)
> return;
> }
>
> - /*
> - * If we still have access to the event_data via handle,
> - * confirm that we haven't messed up the tracking.
> - */
> - if (handle->event &&
> - WARN_ON(perf_get_aux(handle) != ctxt->event_data))
> - return;
> -
> event_data = READ_ONCE(ctxt->event_data);
> /* Clear the event_data as this ETM is stopping the trace. */
> WRITE_ONCE(ctxt->event_data, NULL);
> @@ -743,10 +732,6 @@ static void etm_event_stop(struct perf_event *event, int mode)
> if (event->hw.state == PERF_HES_STOPPED)
> return;
>
> - /* We must have a valid event_data for a running event */
> - if (WARN_ON(!event_data))
> - return;
> -
> source = coresight_get_source(path);
> sink = coresight_get_sink(path);
> if (!source || !sink)
>
Reviewed-by: James Clark <james.clark at linaro.org>
More information about the linux-arm-kernel
mailing list