From: Leo Yan <leo.yan@arm.com>
To: James Clark <james.clark@linaro.org>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@linaro.org>,
Jie Gan <jie.gan@oss.qualcomm.com>,
Carl Worth <carl@os.amperecomputing.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Tingwei Zhang <tingwei.zhang@oss.qualcomm.com>,
coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC 1/3] coresight: tmc: add the handle of the event to the path
Date: Thu, 25 Sep 2025 17:01:23 +0100 [thread overview]
Message-ID: <20250925160123.GC7985@e132581.arm.com> (raw)
In-Reply-To: <635ba698-d7a9-40d0-9285-4ec108d4a536@linaro.org>
On Thu, Sep 25, 2025 at 11:10:51AM +0100, James Clark wrote:
[...]
In short, I prefer to store perf handle in coresight path, as Jie has
done in this series.
I will give details below, sorry for a long replying.
[...]
> This one is just a pointer to the perf handle which really does belong to
> the session rather than the device. This makes it more of a path thing than
> a csdev thing. Maybe we can rename path to be more like "session", which
> also happens to contain a path. But I think path is fine for now.
Yes, renaming 'coresight_path' (to like 'coresight_runtime_ctx') better
reflects the structure’s purpose.
The point is we can take chance to separate runtime parameters from
device and driver instances.
- 'coresight_path': runtime parameters for an active session
- 'coresight_device': a device instance registered on the bus
- driver data: after probe, the driver maintains driver-specific
attributes (e.g., the ETMv4 driver keeps mode and filters in struct
etmv4_drvdata)
These structures have different lifetimes. For example, coresight_path
is valid only during a session; otherwise, it should be cleared.
From a lifecycle perspective, storing the perf handle in coresight_path
makes sense, since both are valid only for the duration of a session
(the perf handle isn't used in sysfs mode, in which case we can simply
leave it unset).
Furthermore, the perf handle is not just a handle; it lets us easily
retrieve private event data (see perf_get_aux()).
> However in this case handle is per-cpu data that is only accessed on the
> same cpu in tmc_etr_get_buffer(). Assigning it in etm_event_start() just
> copies the same per-cpu variable into a non per-cpu place that eventually
> gets accessed on the same cpu anyway.
>
> If we exported it then it can be used directly without worrying where to
> store it:
We need to be careful for exporting data structures across modules, as
it makes them harder to manage.
In fact, we already share 'etm_event_data' for ETR driver for the same
purpose, and seems to me, it is redendant to export another structure
'etm_ctxt' to just make it convenient for obtaining a buffer config
pointer.
> diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c
> b/drivers/hwtracing/coresight/coresight-etm-perf.c
> index 17afa0f4cdee..4c33f442c80b 100644
> --- a/drivers/hwtracing/coresight/coresight-etm-perf.c
> +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
> @@ -42,12 +42,8 @@ static bool etm_perf_up;
> * the ETM. Thus the event_data for the session must be part of the ETM
> context
> * to make sure we can disable the trace path.
> */
> -struct etm_ctxt {
> - struct perf_output_handle handle;
> - struct etm_event_data *event_data;
> -};
> -
> -static DEFINE_PER_CPU(struct etm_ctxt, etm_ctxt);
> +DEFINE_PER_CPU(struct etm_ctxt, etm_ctxt);
> +EXPORT_SYMBOL_GPL(etm_ctxt);
I'd suggest a different approach: drop the etm_ctxt structure and
instead define a per-CPU pointer to etm_event_data:
static DEFINE_PER_CPU(struct etm_event_data *, etm_ev_ctx);
As mentioned above, if perf handle is maintained in coresight_path, we
can easily retrieve the etm_event_data via the perf handle.
A more aggressive refactoring would remove etm_ctxt from
coresight-etm-perf.c entirely, relying on the perf event to manage
private context data. For now, we keep it only to validate whether
ETM is enabled (see multiple place to validate ctxt->event_data).
Thanks,
Leo
next prev parent reply other threads:[~2025-09-25 16:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-22 7:31 [PATCH RFC 0/3] coresight: replace the void pointer with coresight_path pointer Jie Gan
2025-09-22 7:31 ` [PATCH RFC 1/3] coresight: tmc: add the handle of the event to the path Jie Gan
2025-09-22 8:29 ` Leo Yan
2025-09-22 9:19 ` Jie Gan
2025-09-22 17:31 ` Carl Worth
2025-09-23 1:49 ` Jie Gan
2025-09-24 10:21 ` Mike Leach
2025-09-24 16:42 ` Suzuki K Poulose
2025-09-25 10:10 ` James Clark
2025-09-25 16:01 ` Leo Yan [this message]
2025-09-25 16:04 ` Leo Yan
2025-09-26 10:05 ` Mike Leach
2025-09-24 16:28 ` Carl Worth
2025-09-22 7:31 ` [PATCH RFC 2/3] coresight: change helper_ops to accept coresight_path Jie Gan
2025-09-22 8:34 ` Leo Yan
2025-09-22 17:33 ` Carl Worth
2025-09-22 7:31 ` [PATCH RFC 3/3] coresight: change the sink_ops " Jie Gan
2025-09-22 8:46 ` Leo Yan
2025-09-22 17:34 ` Carl Worth
2025-09-22 17:26 ` [PATCH RFC 0/3] coresight: replace the void pointer with coresight_path pointer Carl Worth
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=20250925160123.GC7985@e132581.arm.com \
--to=leo.yan@arm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=carl@os.amperecomputing.com \
--cc=coresight@lists.linaro.org \
--cc=james.clark@linaro.org \
--cc=jie.gan@oss.qualcomm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.leach@linaro.org \
--cc=suzuki.poulose@arm.com \
--cc=tingwei.zhang@oss.qualcomm.com \
/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;
as well as URLs for NNTP newsgroup(s).