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 33D75C433DB for ; Thu, 4 Mar 2021 14:27:45 +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 B9C9E64F31 for ; Thu, 4 Mar 2021 14:27:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9C9E64F31 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=m2xEKo70ZNEYuhSd82BuTE+9ZYzaZYW8QC3PIBD/BzA=; b=ixJuxSUopHdoem4Ym1IVBI6ta KaFwnz3hDFk/ml5b9G95zVWfwQ7vHB9cyfH9UOB145WqsTp6CPEMyDHvu8kNEBPJ189bUM7RI6iMd RvRCPCp8P19kdwzlUefGr2Vpl3WwaBlzb+TGjxiLdbDJTdrSbL7A11Rl7C01zzcKUf5U66iblN326 wvus3Dc6UGtPrKpdvJf18nMx+xZHNVyNj8d0Azv3cSAUTIzg31IV7AbfbBqyXBb+ZhGYebPy9e8I+ O5lxmshWmbgepVo7UupkiHI8uLFX33gyBHHsp7HJDQOcM0kkgX9xO6Al9/U0PiVvujP8nEMqPv5W1 G89Fncx/A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHovE-008tFP-QZ; Thu, 04 Mar 2021 14:25:49 +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 1lHovA-008tF4-SH for linux-arm-kernel@desiato.infradead.org; Thu, 04 Mar 2021 14:25:45 +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=X4EZw5nmDBdHIlqvmBrUKbGAtvGLJyBPj99df8jTsF4=; b=jaO/Jj/tqlN1bnlcOKw8JkDEy/ uyrfOJB5MaZ1tns8cp3ijRG0FHNzS00+7dAga+bmc/sY610B2sJIR/NNGK+GHgZbmETFlIPRKT0f4 Sn1CVdiXpeRckH9VJZsNLnvkf+RhNR2Z54a++NpDDhhh0SL52lvJ2pTqUV2ItFe1MARFbVQdE+24I 0ghZoz/sSxhfgD0o84fuzry2smHXjVWL+BD3ScZnh+LoT2Ua6O5P5v2Aj1k0+ZIHQE+h4jvo04Xyt EqWqa5nNhQuRxLBeqMH/6InNIrphsJZR9OGdE7XALsqZjuOpY/1Y8O7h2VAV1rbdZoCIphrTUD75Z /c7UN/Ew==; Received: from foss.arm.com ([217.140.110.172]) by casper.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHoux-007My3-BU for linux-arm-kernel@lists.infradead.org; Thu, 04 Mar 2021 14:25:36 +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 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-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210304_142536_254847_30256054 X-CRM114-Status: GOOD ( 24.79 ) 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 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel