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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 E9DD9C433DB for ; Thu, 4 Mar 2021 12:16:12 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7CEF4601FB for ; Thu, 4 Mar 2021 12:16:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CEF4601FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KaarJH0HJHh35qjm412qI7srMGkaXhMcHzQwRwLYdzs=; b=SxeXIze88vohWJKCDl9KUu1CY fNrfE8HuXmi7/XNT4OYtEAoc9UYBIGnAVkzjOb+Z/cac020yc+1gwcW2/NK89snLTO9W79F99y0J9 K483KuU/uWC/gRKK3j3idN4j3eWXE7V+cJ8FwPCFhoGkq9cOSANM6mjCtFdpAxoKyI0mHtjxq8wcZ BR0QWvkEbcepD1J7atzcZ1ZMdtEGr71KCjdSNJ0Ed85AtjipZDwx0SD5cl4QWlc7/H1vyrDnVdJCf 0rBlwUi+/3J8JohCWx3DPFm6jU1bmBJY8pE7KUIqC3Nn786har2jieitNZEPAj5+pg3u2/X0W8Ezs xZyFPIEDQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHms9-008ZOt-7D; Thu, 04 Mar 2021 12:14:29 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHms6-008ZOM-34 for linux-arm-kernel@desiato.infradead.org; Thu, 04 Mar 2021 12:14:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description; bh=H5tfFfoPUympww9Eo3kLWptPVJ08a+yyfeTPbZNWU80=; b=jHP8LY4zIKGw5ArP9si71hvDBu r7JqMu8wtUapXJlqpiyq/4lgC1c1YeGljA4W0uqFleyipc0jHog1ftVU7/xLGXekgOjCx4xC4NRyx eS51kgv9vNKCFWRJad+IRh+Q4p3rxI7pMalk/Tm1xZqSpG4o4xUGqogiqudySfA9Nj7X2Nzs2shgC NgN9DFy4ZlixJeC66Gc0edLB+vLSOcmf7N+pRh5Qin5YUQi3SNl+hfWPH/N99SW/jTQD0I8GarZJQ +O3/qFzKUP2RBKIlyd/tyrfGW2+Zpw+ZlyU7hlAeZJOT6vn7/ctlMMwWSDD8Z1JcIo3GuRJTvgGhy +wK2yf5A==; Received: from foss.arm.com ([217.140.110.172]) by casper.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHmri-006xGJ-Ex for linux-arm-kernel@lists.infradead.org; Thu, 04 Mar 2021 12:14:09 +0000 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 A5F1F31B; Thu, 4 Mar 2021 04:13:54 -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 E92363F7D7; Thu, 4 Mar 2021 04:13:51 -0800 (PST) Subject: Re: [PATCH v4 04/10] coresight: etm-perf: update to handle configuration selection To: Mike Leach , linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org, linux-doc@vger.kernel.org Cc: yabinc@google.com, corbet@lwn.net, leo.yan@linaro.org, alexander.shishkin@linux.intel.com, tingwei@codeaurora.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org References: <20210128170936.9222-1-mike.leach@linaro.org> <20210128170936.9222-5-mike.leach@linaro.org> From: Suzuki K Poulose Message-ID: <641a0d20-bf3d-24e2-8402-d99de9117584@arm.com> Date: Thu, 4 Mar 2021 12:13:48 +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: <20210128170936.9222-5-mike.leach@linaro.org> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210304_121408_914552_480ED011 X-CRM114-Status: GOOD ( 33.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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(-) > > diff --git a/drivers/hwtracing/coresight/coresight-config.h b/drivers/hwtracing/coresight/coresight-config.h > index 9d66e0071f38..98380b496046 100644 > --- a/drivers/hwtracing/coresight/coresight-config.h > +++ b/drivers/hwtracing/coresight/coresight-config.h > @@ -154,7 +154,8 @@ struct cscfg_config_feat_ref { > * @nr_presets: Number of sets of presets supplied by this configuration. > * @nr_total_params: Sum of all parameters declared by used features > * @presets: Array of preset values. > - * > + * @id_ea: Extended attribute for perf configid value > + * @event_ea: Extended attribute for perf event value > */ > struct cscfg_config_desc { > const char *name; > @@ -165,6 +166,8 @@ struct cscfg_config_desc { > int nr_presets; > int nr_total_params; > const u64 *presets; /* nr_presets * nr_total_params */ > + struct dev_ext_attribute *id_ea; > + struct dev_ext_attribute *event_ea; > }; > > /** > diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c > index a608081bd446..e270bb1e0f7d 100644 > --- a/drivers/hwtracing/coresight/coresight-etm-perf.c > +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c > @@ -18,8 +18,10 @@ > #include > #include > > +#include "coresight-config.h" > #include "coresight-etm-perf.h" > #include "coresight-priv.h" > +#include "coresight-syscfg.h" > > static struct pmu etm_pmu; > static bool etm_perf_up; > @@ -32,8 +34,13 @@ PMU_FORMAT_ATTR(cycacc, "config:" __stringify(ETM_OPT_CYCACC)); > PMU_FORMAT_ATTR(contextid, "config:" __stringify(ETM_OPT_CTXTID)); > PMU_FORMAT_ATTR(timestamp, "config:" __stringify(ETM_OPT_TS)); > PMU_FORMAT_ATTR(retstack, "config:" __stringify(ETM_OPT_RETSTK)); > +/* preset - if sink ID is used as a configuration selector */ > +PMU_FORMAT_ATTR(preset, "config:0-3"); > /* Sink ID - same for all ETMs */ > PMU_FORMAT_ATTR(sinkid, "config2:0-31"); > +/* config ID - set if a system configuration is selected */ > +PMU_FORMAT_ATTR(configid, "config2:32-63"); > + > > static struct attribute *etm_config_formats_attr[] = { > &format_attr_cycacc.attr, > @@ -41,6 +48,8 @@ static struct attribute *etm_config_formats_attr[] = { > &format_attr_timestamp.attr, > &format_attr_retstack.attr, > &format_attr_sinkid.attr, > + &format_attr_preset.attr, > + &format_attr_configid.attr, > NULL, > }; > > @@ -58,9 +67,29 @@ static const struct attribute_group etm_pmu_sinks_group = { > .attrs = etm_config_sinks_attr, > }; > > +static struct attribute *etm_config_cscfg_attr[] = { > + NULL, > +}; > + > +static const struct attribute_group etm_pmu_cscfg_group = { > + .name = "configurations", > + .attrs = etm_config_cscfg_attr, > +}; > + > +static struct attribute *etm_config_events_attr[] = { > + NULL, > +}; > + > +static const struct attribute_group etm_pmu_events_group = { > + .name = "events", > + .attrs = etm_config_events_attr, > +}; > + > static const struct attribute_group *etm_pmu_attr_groups[] = { > &etm_pmu_format_group, > &etm_pmu_sinks_group, > + &etm_pmu_cscfg_group, > + &etm_pmu_events_group, > NULL, > }; > > @@ -219,7 +248,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, > INIT_WORK(&event_data->work, free_event_data); > > /* First get the selected sink from user space. */ > - if (event->attr.config2) { > + if (event->attr.config2 & GENMASK_ULL(31, 0)) { > id = (u32)event->attr.config2; > sink = coresight_get_sink_by_id(id); > } > @@ -537,21 +566,17 @@ static ssize_t etm_perf_sink_name_show(struct device *dev, > return scnprintf(buf, PAGE_SIZE, "0x%lx\n", (unsigned long)(ea->var)); > } > > -int etm_perf_add_symlink_sink(struct coresight_device *csdev) > +int etm_perf_add_symlink_group(struct device *dev, > + struct dev_ext_attribute **ext_attr, > + const char *name, > + const char *group_name) Couple of nits: This could be: struct dev_ext_attribute * etm_perf_add_to_group_hashed(struct device *dev, const char *group, const char *name) { } This could return the ea on success avoiding the **ext_attr as argument. Also the name of the function indicates what it does. > { > - int ret; > + struct dev_ext_attribute *ea; > unsigned long hash; > - const char *name; > + int ret; > struct device *pmu_dev = etm_pmu.dev; > - struct device *dev = &csdev->dev; > - struct dev_ext_attribute *ea; > > - if (csdev->type != CORESIGHT_DEV_TYPE_SINK && > - csdev->type != CORESIGHT_DEV_TYPE_LINKSINK) > - return -EINVAL; > - > - if (csdev->ea != NULL) > - return -EINVAL; > + *ext_attr = NULL; > > if (!etm_perf_up) > return -EPROBE_DEFER; > @@ -560,7 +585,6 @@ int etm_perf_add_symlink_sink(struct coresight_device *csdev) > if (!ea) > return -ENOMEM; > > - name = dev_name(dev); > /* See function coresight_get_sink_by_id() to know where this is used */ > hash = hashlen_hash(hashlen_string(NULL, name)); > > @@ -574,31 +598,127 @@ int etm_perf_add_symlink_sink(struct coresight_device *csdev) > ea->var = (unsigned long *)hash; > > ret = sysfs_add_file_to_group(&pmu_dev->kobj, > - &ea->attr.attr, "sinks"); > - > + &ea->attr.attr, group_name); > if (!ret) > - csdev->ea = ea; > - > + *ext_attr = ea; > return ret; > } > > -void etm_perf_del_symlink_sink(struct coresight_device *csdev) > +int etm_perf_add_symlink_sink(struct coresight_device *csdev) > +{ > + const char *name; > + struct device *dev = &csdev->dev; > + > + if (csdev->type != CORESIGHT_DEV_TYPE_SINK && > + csdev->type != CORESIGHT_DEV_TYPE_LINKSINK) > + return -EINVAL; > + > + if (csdev->ea != NULL) > + return -EINVAL; > + > + name = dev_name(dev); > + return etm_perf_add_symlink_group(dev, &csdev->ea, name, "sinks"); > +} > + > +void etm_perf_del_symlink_group(struct dev_ext_attribute *ea, const char *group_name) void etm_perf_del_from_group(group, ea) > > +/* string to contain the attribute value */ > +#define CSCFG_EVENT_STR_SIZE 32 > + > +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 ? > + > +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 ? > + > + scnprintf(ea->var, CSCFG_EVENT_STR_SIZE, "configid=0x%lx", hash); > + ea->attr.attr.mode = 0444; > + ea->attr.show = etm_perf_cscfg_event_show; > + > + ret = sysfs_add_file_to_group(&pmu_dev->kobj, > + &ea->attr.attr, "events"); > + if (!ret) > + cs_cfg->event_ea = ea; > + return ret; > +} > + > +int etm_perf_add_symlink_cscfg(struct device *dev, struct cscfg_config_desc *cs_cfg) etm_perf_add_cscfg() ? > +{ > + int err; > + > + if (cs_cfg->id_ea != NULL) > + return 0; > + > + err = etm_perf_add_symlink_group(dev, &cs_cfg->id_ea, > + cs_cfg->name, "configurations"); > + > + if (!err) > + err = etm_perf_add_cscfg_event(dev, cs_cfg); > + > + return err; > +} > + > +void etm_perf_del_symlink_cscfg(struct cscfg_config_desc *cs_cfg) etm_perf_del_cscfg() ? Suzuki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel