Message ID | 20231009051753.179355-1-anshuman.khandual@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1660922vqo; Sun, 8 Oct 2023 22:18:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIQjXXT5+fi3Lr4OTmm5S1HbpAjfIbjygzCg8seGtkOrMSFtSVbvsWYcDj0HEc1S1Ys0Mp X-Received: by 2002:a17:902:6f02:b0:1c5:cd1c:46f6 with SMTP id w2-20020a1709026f0200b001c5cd1c46f6mr10849352plk.24.1696828693210; Sun, 08 Oct 2023 22:18:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696828693; cv=none; d=google.com; s=arc-20160816; b=JWRc0zHlg1DxIM3SVOw4paQZZgEQQVr+JQhIYT3gl3F6fyTDEq719XNVHiGfBOLF9Z NMUxu7eb+XcPNYGZcgqPd2DTsSpvAG5kWtx6iVuFddKmxoQ1oab1M3Qa54BRNQeuGN89 G4jX/mSGVhXbGyTsn6ijWWlsAGFIVNpHYrlO15v9J7Mrv5sTMTSo6eYhTUpzyBvCYT6Q F7D+2g/wttJxxkj3F3W7AzfrcRkKTKq2I+9FiRPY54bW2EY+RhMQxfYZZWc1HqVk2O1+ 3Gcz59MqVhO0KCYMC5jw0wzad03TXPg9pCnd1sWQzigh8+J2tD/4aiU7sE03PqGhRtxv GwOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=1pvQpH7Tz5KDa6aqu4hnr8u/19OuwE9Lit6lECXIxzs=; fh=s03SIMIeJHh4tNM3mw7pRMBjGeQiA04Y7AfUJ3pCpAI=; b=0SKMmrJc1SgZCjyjK/NrnJwKddQzBPuuTw2268rwCZ8KE2CLtsCNHsuCAsk8Pcguua oWPe7LJ7nbTd5cyBDiJydD6t1U3R/uwUsj8kbBrHO8BiJWAfdMADvMVsYCwBHNEH1WFZ XoFW4fDoywuYoJ6pO9YA13P54513g/vnTrBqZDZDq5ko0gn8z/DYF4rJ+7p5t5u8spod 2IPShZq9FnG9fz7pHv8vtReIyIFRNo60S5HZJ5S2ddXbSEmymX0M0NgLWZl+EZMWZ72y BoFXw/8gBcgH7pm9SEovSfTBrMRK/Et/Mk/cqXgUugKZwYN6HDR+AeMLBsTsOXM3FC+V BvrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id kb5-20020a170903338500b001bda18ea0e1si8530917plb.80.2023.10.08.22.18.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 22:18:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 8C64280C590C; Sun, 8 Oct 2023 22:18:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345098AbjJIFSJ (ORCPT <rfc822;ezelljr.billy@gmail.com> + 18 others); Mon, 9 Oct 2023 01:18:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345099AbjJIFSI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 9 Oct 2023 01:18:08 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 50695FA for <linux-kernel@vger.kernel.org>; Sun, 8 Oct 2023 22:18:02 -0700 (PDT) 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 41FB21FB; Sun, 8 Oct 2023 22:18:42 -0700 (PDT) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.41.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E2F523F7A6; Sun, 8 Oct 2023 22:17:59 -0700 (PDT) From: Anshuman Khandual <anshuman.khandual@arm.com> To: linux-arm-kernel@lists.infradead.org Cc: Anshuman Khandual <anshuman.khandual@arm.com>, Will Deacon <will@kernel.org>, Mark Rutland <mark.rutland@arm.com>, linux-kernel@vger.kernel.org Subject: [PATCH] driver: perf: arm_pmuv3: Identify 'event->attr.config1' based attributes Date: Mon, 9 Oct 2023 10:47:53 +0530 Message-Id: <20231009051753.179355-1-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 08 Oct 2023 22:18:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779253844088641315 X-GMAIL-MSGID: 1779253844088641315 |
Series |
driver: perf: arm_pmuv3: Identify 'event->attr.config1' based attributes
|
|
Commit Message
Anshuman Khandual
Oct. 9, 2023, 5:17 a.m. UTC
This defines macros to identify long and rdpmc attributes which get carried
inside 'event->attr.config1', thus making the code explicit and clear.
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
This applies on v6.6-rc5.
drivers/perf/arm_pmuv3.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
Comments
On Mon, Oct 09, 2023 at 10:47:53AM +0530, Anshuman Khandual wrote: > This defines macros to identify long and rdpmc attributes which get carried > inside 'event->attr.config1', thus making the code explicit and clear. > > Cc: Will Deacon <will@kernel.org> > Cc: Mark Rutland <mark.rutland@arm.com> > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> > --- > This applies on v6.6-rc5. > > drivers/perf/arm_pmuv3.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) I think this would make sense to do if we also used a common definition of these bits in the helper functions *and* their format attributes, but as-is this does nothing to relate the two, and I don't think that it improves legibility on its own. Mark. > diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c > index 94723d00548e..797ffd5a8fed 100644 > --- a/drivers/perf/arm_pmuv3.c > +++ b/drivers/perf/arm_pmuv3.c > @@ -298,16 +298,19 @@ PMU_FORMAT_ATTR(event, "config:0-15"); > PMU_FORMAT_ATTR(long, "config1:0"); > PMU_FORMAT_ATTR(rdpmc, "config1:1"); > > +#define ARM_PMUV3_ATTR_LONG 0x01 > +#define ARM_PMUV3_ATTR_RDPMC 0x02 > + > static int sysctl_perf_user_access __read_mostly; > > static inline bool armv8pmu_event_is_64bit(struct perf_event *event) > { > - return event->attr.config1 & 0x1; > + return event->attr.config1 & ARM_PMUV3_ATTR_LONG; > } > > static inline bool armv8pmu_event_want_user_access(struct perf_event *event) > { > - return event->attr.config1 & 0x2; > + return event->attr.config1 & ARM_PMUV3_ATTR_RDPMC; > } > > static struct attribute *armv8_pmuv3_format_attrs[] = { > -- > 2.25.1 >
On 10/13/23 19:17, Mark Rutland wrote: > On Mon, Oct 09, 2023 at 10:47:53AM +0530, Anshuman Khandual wrote: >> This defines macros to identify long and rdpmc attributes which get carried >> inside 'event->attr.config1', thus making the code explicit and clear. >> >> Cc: Will Deacon <will@kernel.org> >> Cc: Mark Rutland <mark.rutland@arm.com> >> Cc: linux-arm-kernel@lists.infradead.org >> Cc: linux-kernel@vger.kernel.org >> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> >> --- >> This applies on v6.6-rc5. >> >> drivers/perf/arm_pmuv3.c | 7 +++++-- >> 1 file changed, 5 insertions(+), 2 deletions(-) I am not sure, if I understand your concerns and/or suggestions properly. > > I think this would make sense to do if we also used a common definition of > these bits in the helper functions *and* their format attributes, but as-is Common definitions of sysfs formats ? Which helper - linux/perf/arm_pmuv3.h ? > this does nothing to relate the two, and I don't think that it improves > legibility on its own. Currently armv8pmu_event_is_64bit() and armv8pmu_event_want_user_access() extracts required values from 'event->attr.config1' with hard coded masks without any explicit co-relation with PMU_FORMAT_ATTR() described formats above, unless some one really looks into the config1 bits layout. Could you please provide some more details on how to go about making this change better. > > Mark. > >> diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c >> index 94723d00548e..797ffd5a8fed 100644 >> --- a/drivers/perf/arm_pmuv3.c >> +++ b/drivers/perf/arm_pmuv3.c >> @@ -298,16 +298,19 @@ PMU_FORMAT_ATTR(event, "config:0-15"); >> PMU_FORMAT_ATTR(long, "config1:0"); >> PMU_FORMAT_ATTR(rdpmc, "config1:1"); >> >> +#define ARM_PMUV3_ATTR_LONG 0x01 >> +#define ARM_PMUV3_ATTR_RDPMC 0x02 >> + >> static int sysctl_perf_user_access __read_mostly; >> >> static inline bool armv8pmu_event_is_64bit(struct perf_event *event) >> { >> - return event->attr.config1 & 0x1; >> + return event->attr.config1 & ARM_PMUV3_ATTR_LONG; >> } >> >> static inline bool armv8pmu_event_want_user_access(struct perf_event *event) >> { >> - return event->attr.config1 & 0x2; >> + return event->attr.config1 & ARM_PMUV3_ATTR_RDPMC; >> } >> >> static struct attribute *armv8_pmuv3_format_attrs[] = { >> -- >> 2.25.1 >>
diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c index 94723d00548e..797ffd5a8fed 100644 --- a/drivers/perf/arm_pmuv3.c +++ b/drivers/perf/arm_pmuv3.c @@ -298,16 +298,19 @@ PMU_FORMAT_ATTR(event, "config:0-15"); PMU_FORMAT_ATTR(long, "config1:0"); PMU_FORMAT_ATTR(rdpmc, "config1:1"); +#define ARM_PMUV3_ATTR_LONG 0x01 +#define ARM_PMUV3_ATTR_RDPMC 0x02 + static int sysctl_perf_user_access __read_mostly; static inline bool armv8pmu_event_is_64bit(struct perf_event *event) { - return event->attr.config1 & 0x1; + return event->attr.config1 & ARM_PMUV3_ATTR_LONG; } static inline bool armv8pmu_event_want_user_access(struct perf_event *event) { - return event->attr.config1 & 0x2; + return event->attr.config1 & ARM_PMUV3_ATTR_RDPMC; } static struct attribute *armv8_pmuv3_format_attrs[] = {