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.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, 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 05CDFC4708F for ; Wed, 2 Jun 2021 09:51:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C91A86101B for ; Wed, 2 Jun 2021 09:51:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C91A86101B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3pdUXaiW1JMd8yWgiEWN+Iqg2Fq2kZoC4/X8RO3UFWI=; b=bDQCOx/6ZG36kV jbyEYBj1vMUKFLX2Xhj5qZvY7IjTQ35N6FFPc/uapCGDIXQsKebRTRA0c1GK+1JyVWEuao8oPWU/B wKlRsDyS5p3DNFmYRiwJ9S/wVRoZanXTLrZrODVBgkK3yW0aL/bd1VCLcW/veBlYJMyvrD1T2t47a IRqyIiVfa8BB0NeNj0O3ePD1sx0h2k5s2P/B+70WMc96RiYgp7U6PhY8f2kIAqYWLhXOtOr02tqDK qPE/K8wIX3VRcHA8LCh8A454lXDlOSw6h145AA3mNqtp4jUcZJry4AgZGvGe/HZDnQNAK1wujR8BQ 6+svU0Z8HCyPW6EyydFQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1loNVH-0034Tt-UP; Wed, 02 Jun 2021 09:49:36 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1loNVA-0034SX-8y for linux-arm-kernel@lists.infradead.org; Wed, 02 Jun 2021 09:49:29 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6B90E6101B; Wed, 2 Jun 2021 09:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622627367; bh=CugNKS2a3ZZprq8U1OraauTxEfAA1k4urBEESTDF1Ok=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DWYMsfZJrKTYhD/qmo8nNe/Y9jikdpFvBwhFF9SM0SEeENrtErG7494QRXakockZJ ppZGL/kBXn4do/UVvE2JagUUVGhFa5USn0qtXd4bLfkmwRks/e0NGWmnlF7z8fzH8d LQ1GFAcP19puxWDsJGG6Y7m+2eTdIc3ClW30eBByFUkflUaXqglQXEhp+Dyfy5GOx0 kWwh+bZM+o0Dxjn0jdB+NXYH8ZbCY823XIzFG4fsVnd1ItHxiMHRFH5HZ6L8/wAxUw oFiBxOOLjWYUvtniTkVdOTgDX+gw5QN/zsbZYmfAv4V+luY9aVPPgbK8jpkT5XrPaS ESRK5cCoBXNZg== Date: Wed, 2 Jun 2021 10:49:22 +0100 From: Will Deacon To: "liuqi (BA)" Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Linuxarm Subject: Re: [PATCH v2 1/9] perf: Add EVENT_ATTR_ID to simplify event attributes Message-ID: <20210602094922.GA30503@willie-the-truck> References: <1621417919-6632-1-git-send-email-liuqi115@huawei.com> <1621417919-6632-2-git-send-email-liuqi115@huawei.com> <20210601131020.GD28025@willie-the-truck> <30abdbec-3174-1f8a-47d4-63a4de3b1e47@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <30abdbec-3174-1f8a-47d4-63a4de3b1e47@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210602_024928_416275_29253B7E X-CRM114-Status: GOOD ( 27.84 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jun 02, 2021 at 04:45:23PM +0800, liuqi (BA) wrote: > > Hi Will, > > Thanks for reviewing this patch. > > On 2021/6/1 21:10, Will Deacon wrote: > > On Wed, May 19, 2021 at 05:51:51PM +0800, Qi Liu wrote: > > > Similar EVENT_ATTR macros are defined in many PMU drivers, > > > like HiSilicon PMU driver, Arm PMU driver, Arm SMMU PMU > > > driver. So Add a generic macro to simplify code. > > > > > > Cc: Peter Zijlstra > > > Cc: Ingo Molnar > > > Cc: Arnaldo Carvalho de Melo > > > Cc: Mark Rutland > > > Cc: Alexander Shishkin > > > Signed-off-by: Qi Liu > > > --- > > > include/linux/perf_event.h | 6 ++++++ > > > kernel/events/core.c | 2 ++ > > > 2 files changed, 8 insertions(+) > > > > > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > > > index f5a6a2f..d0aa74e 100644 > > > --- a/include/linux/perf_event.h > > > +++ b/include/linux/perf_event.h > > > @@ -1576,6 +1576,12 @@ static struct perf_pmu_events_attr _var = { \ > > > .event_str = _str, \ > > > }; > > > +#define PMU_EVENT_ATTR_ID(_name, _id) \ > > > + (&((struct perf_pmu_events_attr[]) { \ > > > + { .attr = __ATTR(_name, 0444, perf_event_sysfs_show, NULL), \ > > > + .id = _id, } \ > > > + })[0].attr.attr) > > > + > > > #define PMU_FORMAT_ATTR(_name, _format) \ > > > static ssize_t \ > > > _name##_show(struct device *dev, \ > > > diff --git a/kernel/events/core.c b/kernel/events/core.c > > > index 0ac818b..330d9cc 100644 > > > --- a/kernel/events/core.c > > > +++ b/kernel/events/core.c > > > @@ -13295,6 +13295,8 @@ ssize_t perf_event_sysfs_show(struct device *dev, struct device_attribute *attr, > > > if (pmu_attr->event_str) > > > return sprintf(page, "%s\n", pmu_attr->event_str); > > > + else > > > + return sprintf(page, "config=%#llx\n", pmu_attr->id); > > > > I think it's a really bad idea to hardcode this here. For example, I think > > this patch series breaks user ABI for the SMMU PMU which used to print: > > > > "event=0x%02llx\n" > > > > and by the looks of it many of the other conversions are unsound too. > > > Got it, so I'll use pmu_attr->event_str here, for example, > SMMU_EVENT_ATTR(cycles, "event=0x00") You could, but honestly I don't really see this being any better than the current code. The advantage of using "event=0x%02llx\n" is that things are consistent by construction and therefore userspace can parse the information easily. We lose that if we just hardcode the string and it's error-prone to extend. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel