From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AEFBC433E0 for ; Thu, 4 Mar 2021 14:26:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4AF5264F27 for ; Thu, 4 Mar 2021 14:26:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230495AbhCDO01 (ORCPT ); Thu, 4 Mar 2021 09:26:27 -0500 Received: from foss.arm.com ([217.140.110.172]:39136 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231216AbhCDO0J (ORCPT ); Thu, 4 Mar 2021 09:26:09 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 586931FB; Thu, 4 Mar 2021 06:25:22 -0800 (PST) Received: from [10.57.63.81] (unknown [10.57.63.81]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F1F1D3F766; Thu, 4 Mar 2021 06:25:19 -0800 (PST) Subject: Re: [PATCH v4 04/10] coresight: etm-perf: update to handle configuration selection To: Mike Leach Cc: linux-arm-kernel , Coresight ML , Mathieu Poirier , "open list:DOCUMENTATION" , Yabin Cui , Jonathan Corbet , Leo Yan , Alexander Shishkin , Tingwei Zhang , Greg Kroah-Hartman , Linux Kernel Mailing List References: <20210128170936.9222-1-mike.leach@linaro.org> <20210128170936.9222-5-mike.leach@linaro.org> <641a0d20-bf3d-24e2-8402-d99de9117584@arm.com> From: Suzuki K Poulose Message-ID: <921225a2-14a8-2a4f-4726-f61224cafa28@arm.com> Date: Thu, 4 Mar 2021 14:25:16 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On 3/4/21 2:19 PM, Mike Leach wrote: > Hi Suzuki, > > On Thu, 4 Mar 2021 at 12:13, Suzuki K Poulose 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 >>> --- >>> .../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=". >>> + * 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" - 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