Skip to contentSkip to conversation

driver: perf: arm_pmuv3: Identify 'event->attr.config1' based attributes

PATCH In review Anshuman Khandual 2 participants 3 messages Oct 9, 2023 – Oct 16, 2023 Arm PMU profiling and debugging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver: perf: arm_pmuv3: Identify 'event->attr.config1' based attributes

This defines macros to identify long and rdpmc attributes which get carried inside 'event->attr.config1', thus making the code explicit and clear.

---
This applies on v6.6-rc5.

 drivers/perf/arm_pmuv3.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/perf/arm_pmuv3.c +5 -2
index 94723d00548e..797ffd5a8fed 100644
@@ -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[] = {
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 8 lines · Anshuman Khandual

This defines macros to identify long and rdpmc attributes which get carried inside 'event->attr.config1', thus making the code explicit and clear.

Quoted 5 lines

---
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.

Quoted 29 lines
drivers/perf/arm_pmuv3.c +5 -2
index 94723d00548e..797ffd5a8fed 100644
@@ -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[] = {
Signature · 1 line
2.25.1
#2 lore raw
Quoted 12 lines · Mark Rutland
Quoted 11 lines · Anshuman Khandual

This defines macros to identify long and rdpmc attributes which get carried inside 'event->attr.config1', thus making the code explicit and clear.

---
This applies on v6.6-rc5.

Quoted 2 lines
Quoted 2 lines
 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.

Quoted 3 lines

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 ?

Quoted 2 lines

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.

Quoted 32 lines

Mark.

Quoted 29 lines
drivers/perf/arm_pmuv3.c +5 -2
index 94723d00548e..797ffd5a8fed 100644
@@ -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[] = {
Signature · 1 line
2.25.1