From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: Mike Leach <mike.leach@linaro.org>
Cc: linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
Coresight ML <coresight@lists.linaro.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
Yabin Cui <yabinc@google.com>, Jonathan Corbet <corbet@lwn.net>,
Leo Yan <leo.yan@linaro.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Tingwei Zhang <tingwei@codeaurora.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 04/10] coresight: etm-perf: update to handle configuration selection
Date: Thu, 4 Mar 2021 14:25:16 +0000 [thread overview]
Message-ID: <921225a2-14a8-2a4f-4726-f61224cafa28@arm.com> (raw)
In-Reply-To: <CAJ9a7Vi5dTJTNRNC36UEwAeCayd_HF9jN8rXSggRF_4cPZ1NrA@mail.gmail.com>
On 3/4/21 2:19 PM, Mike Leach wrote:
> Hi Suzuki,
>
> On Thu, 4 Mar 2021 at 12:13, Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>>
>> On 1/28/21 5:09 PM, Mike Leach wrote:
>>> Loaded coresight configurations are registered in the cs_etm\cs_config sub
>>> directory. This extends the etm-perf code to handle these registrations,
>>> and the cs_syscfg driver to perform the registration on load.
>>>
>>> Signed-off-by: Mike Leach <mike.leach@linaro.org>
>>> ---
>>> .../hwtracing/coresight/coresight-config.h | 5 +-
>>> .../hwtracing/coresight/coresight-etm-perf.c | 164 +++++++++++++++---
>>> .../hwtracing/coresight/coresight-etm-perf.h | 8 +
>>> .../hwtracing/coresight/coresight-syscfg.c | 13 +-
>>> 4 files changed, 166 insertions(+), 24 deletions(-)
>>>
>>> +static ssize_t etm_perf_cscfg_event_show(struct device *dev,
>>> + struct device_attribute *dattr,
>>> + char *buf)
>>> +{
>>> + struct dev_ext_attribute *ea;
>>> +
>>> + ea = container_of(dattr, struct dev_ext_attribute, attr);
>>> + return scnprintf(buf, PAGE_SIZE, "%s\n", (const char *)(ea->var));
>>> +}
>>
>> "configid=0x%lx", (unsigned long)ea->var ?
>>
>
> ea->var _is_ "configid=0x%lx" due to the way perf handles the events
> sub-dir entries.
>
This must be combined with the suggestion below.
>>> +
>>> +static int etm_perf_add_cscfg_event(struct device *dev, struct cscfg_config_desc *cs_cfg)
>>> +{
>>> + struct dev_ext_attribute *ea;
>>> + unsigned long hash;
>>> + int ret;
>>> + struct device *pmu_dev = etm_pmu.dev;
>>> +
>>> + ea = devm_kzalloc(dev, sizeof(*ea), GFP_KERNEL);
>>> + if (!ea)
>>> + return -ENOMEM;
>>> +
>>> + hash = (unsigned long)cs_cfg->id_ea->var;
>>> +
>>> + sysfs_attr_init(&ea->attr.attr);
>>> + ea->attr.attr.name = devm_kstrdup(dev, cs_cfg->name, GFP_KERNEL);
>>> + if (!ea->attr.attr.name)
>>> + return -ENOMEM;
>>> +
>>> + /*
>>> + * attribute value is "configid=<hash>".
>>> + * this will be what perf evaluates when the config name is used
>>> + * on the command line.
>>> + */
>>> + ea->var = devm_kzalloc(dev, CSCFG_EVENT_STR_SIZE, GFP_KERNEL);
>>> + if (!ea->var)
>>> + return -ENOMEM;
>>
>> Could we drop this string and use the "hash" instead ?
>>
>
> No. My understanding is that we have added an events directory to
> cs_etm, and add the configurations in there:-
>
> cs_etm/events/autofdo
>
> Now the contents of autofdo are "configid=0x<hash-value>" - where
> hash-value is the hash of "autofdo".
>
> On the perf command line:-
>
> perf record -e cs_etm/autofdo/ .....
>
> will result in perf parsing autofdo, looking in the events dir for
> cs_etm, seeing the configid=-string, and parsing that to assign to
> configid attribute - which we have allocated to config2:63:32 - this
> will then appear as a value in the perf_event and we can load the
> configuration when starting up the event on the ETM etc.
Sorry, I was not explicit in my comments. You could drop the string and
have ea->var = hash. And the _show() could simply do
"configid=0x%lx" , hash
as mentioned above.
That would avoid another string allocation, with the same interface.
Suzuki
next prev parent reply other threads:[~2021-03-04 14:26 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 17:09 [PATCH v4 00/10] CoreSight configuration management; ETM strobing Mike Leach
2021-01-28 17:09 ` [PATCH v4 01/10] coresight: syscfg: Initial coresight system configuration Mike Leach
2021-02-18 23:52 ` Mathieu Poirier
2021-02-26 19:09 ` Mike Leach
2021-02-22 18:50 ` Mathieu Poirier
2021-02-26 19:10 ` Mike Leach
2021-03-03 10:09 ` Suzuki K Poulose
2021-03-03 15:12 ` Mike Leach
2021-03-03 10:23 ` Suzuki K Poulose
2021-03-04 10:08 ` Suzuki K Poulose
2021-03-04 10:47 ` Mike Leach
2021-03-04 10:48 ` Suzuki K Poulose
2021-01-28 17:09 ` [PATCH v4 02/10] coresight: syscfg: Add registration and feature loading for cs devices Mike Leach
2021-02-19 18:43 ` Mathieu Poirier
2021-02-26 19:14 ` Mike Leach
2021-02-27 20:52 ` Mathieu Poirier
2021-02-22 17:37 ` Mathieu Poirier
2021-02-26 19:16 ` Mike Leach
2021-02-22 19:05 ` Mathieu Poirier
2021-03-04 10:33 ` Suzuki K Poulose
2021-03-16 18:00 ` Mike Leach
2021-01-28 17:09 ` [PATCH v4 03/10] coresight: config: Add configuration and feature generic functions Mike Leach
2021-02-22 22:57 ` Mathieu Poirier
2021-03-04 11:25 ` Suzuki K Poulose
2021-01-28 17:09 ` [PATCH v4 04/10] coresight: etm-perf: update to handle configuration selection Mike Leach
2021-02-24 18:33 ` Mathieu Poirier
2021-02-26 19:26 ` Mike Leach
2021-03-04 12:13 ` Suzuki K Poulose
2021-03-04 14:19 ` Mike Leach
2021-03-04 14:25 ` Suzuki K Poulose [this message]
2021-03-04 14:46 ` Mike Leach
2021-01-28 17:09 ` [PATCH v4 05/10] coresight: syscfg: Add API to activate and enable configurations Mike Leach
2021-02-25 21:20 ` Mathieu Poirier
2021-02-25 21:46 ` Mathieu Poirier
2021-02-26 20:08 ` Mike Leach
2021-03-04 16:49 ` Suzuki K Poulose
2021-03-04 18:15 ` Mike Leach
2021-01-28 17:09 ` [PATCH v4 06/10] coresight: etm-perf: Update to activate selected configuration Mike Leach
2021-02-25 21:51 ` Mathieu Poirier
2021-02-26 20:09 ` Mike Leach
2021-03-04 16:50 ` Suzuki K Poulose
2021-01-28 17:09 ` [PATCH v4 07/10] coresight: etm4x: Add complex configuration handlers to etmv4 Mike Leach
2021-02-28 23:19 ` Mathieu Poirier
2021-03-05 10:18 ` Suzuki K Poulose
2021-03-17 15:04 ` Mike Leach
2021-01-28 17:09 ` [PATCH v4 08/10] coresight: config: Add preloaded configurations Mike Leach
2021-02-28 23:25 ` Mathieu Poirier
2021-03-05 13:39 ` Suzuki K Poulose
2021-01-28 17:09 ` [PATCH v4 09/10] coresight: syscfg: Add initial configfs support Mike Leach
2021-03-01 0:02 ` Mathieu Poirier
2021-03-01 0:04 ` Mathieu Poirier
2021-01-28 17:09 ` [PATCH v4 10/10] coresight: docs: Add documentation for CoreSight config Mike Leach
2021-02-18 21:28 ` Mathieu Poirier
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=921225a2-14a8-2a4f-4726-f61224cafa28@arm.com \
--to=suzuki.poulose@arm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=corbet@lwn.net \
--cc=coresight@lists.linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=mike.leach@linaro.org \
--cc=tingwei@codeaurora.org \
--cc=yabinc@google.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).