From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: Leo Yan <leo.yan@arm.com>, Mike Leach <mike.leach@linaro.org>,
James Clark <james.clark@linaro.org>,
Jonathan Corbet <corbet@lwn.net>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 5/6] coresight: perf: Update buffer on AUX pause
Date: Tue, 1 Apr 2025 13:51:36 +0100 [thread overview]
Message-ID: <8d9ad64b-a5f7-4a44-a557-7edb83322fdf@arm.com> (raw)
In-Reply-To: <20250311170451.611389-6-leo.yan@arm.com>
On 11/03/2025 17:04, Leo Yan wrote:
> Due to sinks like ETR and ETB don't support interrupt handling, the
> hardware trace data might be lost for continuous running tasks.
>
> This commit takes advantage of the AUX pause for updating trace buffer
> to mitigate the trace data losing issue.
>
> The per CPU sink has its own interrupt handling. Thus, there will be a
> race condition between the updating buffer in NMI and sink's interrupt
> handler. To avoid the race condition, this commit disallows updating
> buffer on AUX pause for the per CPU sink. Currently, this is only
> applied for TRBE.
>
> Signed-off-by: Leo Yan <leo.yan@arm.com>
> ---
> .../hwtracing/coresight/coresight-etm-perf.c | 43 ++++++++++++++++++-
> 1 file changed, 41 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
> index 2dcf1809cb7f..f1551c08ecb2 100644
> --- a/drivers/hwtracing/coresight/coresight-etm-perf.c
> +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
> @@ -574,14 +574,53 @@ static void etm_event_start(struct perf_event *event, int flags)
> return;
> }
>
> -static void etm_event_pause(struct coresight_device *csdev,
> +static void etm_event_pause(struct perf_event *event,
> + struct coresight_device *csdev,
> struct etm_ctxt *ctxt)
> {
> + int cpu = smp_processor_id();
> + struct coresight_device *sink;
> + struct perf_output_handle *handle = &ctxt->handle;
> + struct coresight_path *path;
> + unsigned long size;
> +
> if (!ctxt->event_data)
> return;
>
> /* Stop tracer */
> coresight_pause_source(csdev);
> +
> + path = etm_event_cpu_path(ctxt->event_data, cpu);
> + sink = coresight_get_sink(path);
> + if (WARN_ON_ONCE(!sink))
> + return;
> +
> + /*
> + * The per CPU sink has own interrupt handling, it might have
> + * race condition with updating buffer on AUX trace pause if
> + * it is invoked from NMI. To avoid the race condition,
> + * disallows updating buffer for the per CPU sink case.
> + */
> + if (coresight_is_percpu_sink(sink))
> + return;
> +
> + if (WARN_ON_ONCE(handle->event != event))
> + return;
> +
> + if (!sink_ops(sink)->update_buffer)
> + return;
> +
> + size = sink_ops(sink)->update_buffer(sink, handle,
> + ctxt->event_data->snk_config);
I believe we keep the sink disabled/stopped in update_buffer. We need to
turn it back ON after the "buffer update". May be we could use a flag
to update_buffer() to indicate this is "pause" triggered update.
Cheers
Suzuki
> + if (READ_ONCE(handle->event)) {
> + if (!size)
> + return;
> +
> + perf_aux_output_end(handle, size);
> + perf_aux_output_begin(handle, event);
> + } else {
> + WARN_ON_ONCE(size);
> + }
> }
>
> static void etm_event_stop(struct perf_event *event, int mode)
> @@ -595,7 +634,7 @@ static void etm_event_stop(struct perf_event *event, int mode)
> struct coresight_path *path;
>
> if (mode & PERF_EF_PAUSE)
> - return etm_event_pause(csdev, ctxt);
> + return etm_event_pause(event, csdev, ctxt);
>
> /*
> * If we still have access to the event_data via handle,
next prev parent reply other threads:[~2025-04-01 12:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 17:04 [PATCH v3 0/6] Arm CoreSight: Support AUX pause and resume Leo Yan
2025-03-11 17:04 ` [PATCH v3 1/6] coresight: etm4x: Extract the trace unit controlling Leo Yan
2025-04-01 8:59 ` Mike Leach
2025-03-11 17:04 ` [PATCH v3 2/6] coresight: Introduce pause and resume APIs for source Leo Yan
2025-04-01 10:01 ` Mike Leach
2025-03-11 17:04 ` [PATCH v3 3/6] coresight: etm4x: Hook pause and resume callbacks Leo Yan
2025-04-01 10:30 ` Mike Leach
2025-03-11 17:04 ` [PATCH v3 4/6] coresight: perf: Support AUX trace pause and resume Leo Yan
2025-04-01 12:50 ` Mike Leach
2025-04-01 15:00 ` Leo Yan
2025-04-02 8:45 ` Mike Leach
2025-04-02 12:31 ` Leo Yan
2025-04-02 12:56 ` Mike Leach
2025-03-11 17:04 ` [PATCH v3 5/6] coresight: perf: Update buffer on AUX pause Leo Yan
2025-04-01 12:51 ` Suzuki K Poulose [this message]
2025-04-01 14:35 ` Mike Leach
2025-04-01 15:08 ` Leo Yan
2025-03-11 17:04 ` [PATCH v3 6/6] Documentation: coresight: Document AUX pause and resume Leo Yan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8d9ad64b-a5f7-4a44-a557-7edb83322fdf@arm.com \
--to=suzuki.poulose@arm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=corbet@lwn.net \
--cc=coresight@lists.linaro.org \
--cc=james.clark@linaro.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.leach@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox