* [PATCH] driver: perf: arm_pmu: Drop some unused arguments from armv8_pmu_init() @ 2023-10-09 3:56 Anshuman Khandual 2023-10-09 9:17 ` James Clark 0 siblings, 1 reply; 5+ messages in thread From: Anshuman Khandual @ 2023-10-09 3:56 UTC (permalink / raw) To: linux-arm-kernel Cc: Anshuman Khandual, Will Deacon, Mark Rutland, linux-kernel There is just a single call site remaining for armv8_pmu_init(), passing on NULL pointers for all custom 'struct attribute_group'. These arguments are not really getting used and hence can just be dropped off, thus simplifying the code further. 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 | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c index 8fcaa26f0f8a..fe4db1831662 100644 --- a/drivers/perf/arm_pmuv3.c +++ b/drivers/perf/arm_pmuv3.c @@ -1187,10 +1187,7 @@ static void armv8_pmu_register_sysctl_table(void) } static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, - int (*map_event)(struct perf_event *event), - const struct attribute_group *events, - const struct attribute_group *format, - const struct attribute_group *caps) + int (*map_event)(struct perf_event *event)) { int ret = armv8pmu_probe_pmu(cpu_pmu); if (ret) @@ -1212,13 +1209,9 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, cpu_pmu->name = name; cpu_pmu->map_event = map_event; - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = events ? - events : &armv8_pmuv3_events_attr_group; - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = format ? - format : &armv8_pmuv3_format_attr_group; - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_CAPS] = caps ? - caps : &armv8_pmuv3_caps_attr_group; - + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = &armv8_pmuv3_events_attr_group; + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = &armv8_pmuv3_format_attr_group; + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_CAPS] = &armv8_pmuv3_caps_attr_group; armv8_pmu_register_sysctl_table(); return 0; } @@ -1226,7 +1219,7 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, static int armv8_pmu_init_nogroups(struct arm_pmu *cpu_pmu, char *name, int (*map_event)(struct perf_event *event)) { - return armv8_pmu_init(cpu_pmu, name, map_event, NULL, NULL, NULL); + return armv8_pmu_init(cpu_pmu, name, map_event); } #define PMUV3_INIT_SIMPLE(name) \ -- 2.25.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] driver: perf: arm_pmu: Drop some unused arguments from armv8_pmu_init() 2023-10-09 3:56 [PATCH] driver: perf: arm_pmu: Drop some unused arguments from armv8_pmu_init() Anshuman Khandual @ 2023-10-09 9:17 ` James Clark 2023-10-10 2:36 ` Anshuman Khandual 2023-10-10 11:59 ` Robin Murphy 0 siblings, 2 replies; 5+ messages in thread From: James Clark @ 2023-10-09 9:17 UTC (permalink / raw) To: Anshuman Khandual, linux-arm-kernel, Robin Murphy Cc: Will Deacon, Mark Rutland, linux-kernel On 09/10/2023 04:56, Anshuman Khandual wrote: > There is just a single call site remaining for armv8_pmu_init(), passing on > NULL pointers for all custom 'struct attribute_group'. These arguments are > not really getting used and hence can just be dropped off, thus simplifying > the code further. > > 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 | 17 +++++------------ > 1 file changed, 5 insertions(+), 12 deletions(-) > > diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c > index 8fcaa26f0f8a..fe4db1831662 100644 > --- a/drivers/perf/arm_pmuv3.c > +++ b/drivers/perf/arm_pmuv3.c > @@ -1187,10 +1187,7 @@ static void armv8_pmu_register_sysctl_table(void) > } > > static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, > - int (*map_event)(struct perf_event *event), > - const struct attribute_group *events, > - const struct attribute_group *format, > - const struct attribute_group *caps) > + int (*map_event)(struct perf_event *event)) > { > int ret = armv8pmu_probe_pmu(cpu_pmu); > if (ret) > @@ -1212,13 +1209,9 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, > > cpu_pmu->name = name; > cpu_pmu->map_event = map_event; > - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = events ? > - events : &armv8_pmuv3_events_attr_group; > - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = format ? > - format : &armv8_pmuv3_format_attr_group; > - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_CAPS] = caps ? > - caps : &armv8_pmuv3_caps_attr_group; > - > + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = &armv8_pmuv3_events_attr_group; > + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = &armv8_pmuv3_format_attr_group; > + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_CAPS] = &armv8_pmuv3_caps_attr_group; > armv8_pmu_register_sysctl_table(); > return 0; > } > @@ -1226,7 +1219,7 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, > static int armv8_pmu_init_nogroups(struct arm_pmu *cpu_pmu, char *name, > int (*map_event)(struct perf_event *event)) > { > - return armv8_pmu_init(cpu_pmu, name, map_event, NULL, NULL, NULL); > + return armv8_pmu_init(cpu_pmu, name, map_event); I think the whole point of the nogroups wrapper was to add the NULLs. If you remove them, then you can remove the nogroups function too and just call armv8_pmu_init() directly instead. And as it wasn't clear why they were there in the first place, I went to look and found this (e424b17) : Although nobody uses non-default sysfs attributes today, there's minimal impact to preserving the notion that maybe, some day, somebody might, so we may as well keep up appearances. It might be worth mentioning that the decision has now been made in the other way. > } > > #define PMUV3_INIT_SIMPLE(name) \ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] driver: perf: arm_pmu: Drop some unused arguments from armv8_pmu_init() 2023-10-09 9:17 ` James Clark @ 2023-10-10 2:36 ` Anshuman Khandual 2023-10-10 11:59 ` Robin Murphy 1 sibling, 0 replies; 5+ messages in thread From: Anshuman Khandual @ 2023-10-10 2:36 UTC (permalink / raw) To: James Clark, linux-arm-kernel, Robin Murphy Cc: Will Deacon, Mark Rutland, linux-kernel Hi James, On 10/9/23 14:47, James Clark wrote: > > > On 09/10/2023 04:56, Anshuman Khandual wrote: >> There is just a single call site remaining for armv8_pmu_init(), passing on >> NULL pointers for all custom 'struct attribute_group'. These arguments are >> not really getting used and hence can just be dropped off, thus simplifying >> the code further. >> >> 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 | 17 +++++------------ >> 1 file changed, 5 insertions(+), 12 deletions(-) >> >> diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c >> index 8fcaa26f0f8a..fe4db1831662 100644 >> --- a/drivers/perf/arm_pmuv3.c >> +++ b/drivers/perf/arm_pmuv3.c >> @@ -1187,10 +1187,7 @@ static void armv8_pmu_register_sysctl_table(void) >> } >> >> static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, >> - int (*map_event)(struct perf_event *event), >> - const struct attribute_group *events, >> - const struct attribute_group *format, >> - const struct attribute_group *caps) >> + int (*map_event)(struct perf_event *event)) >> { >> int ret = armv8pmu_probe_pmu(cpu_pmu); >> if (ret) >> @@ -1212,13 +1209,9 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, >> >> cpu_pmu->name = name; >> cpu_pmu->map_event = map_event; >> - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = events ? >> - events : &armv8_pmuv3_events_attr_group; >> - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = format ? >> - format : &armv8_pmuv3_format_attr_group; >> - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_CAPS] = caps ? >> - caps : &armv8_pmuv3_caps_attr_group; >> - >> + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = &armv8_pmuv3_events_attr_group; >> + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = &armv8_pmuv3_format_attr_group; >> + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_CAPS] = &armv8_pmuv3_caps_attr_group; >> armv8_pmu_register_sysctl_table(); >> return 0; >> } >> @@ -1226,7 +1219,7 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, >> static int armv8_pmu_init_nogroups(struct arm_pmu *cpu_pmu, char *name, >> int (*map_event)(struct perf_event *event)) >> { >> - return armv8_pmu_init(cpu_pmu, name, map_event, NULL, NULL, NULL); >> + return armv8_pmu_init(cpu_pmu, name, map_event); > > I think the whole point of the nogroups wrapper was to add the NULLs. If > you remove them, then you can remove the nogroups function too and just > call armv8_pmu_init() directly instead. Sounds reasonable. Will change all the relevant functions to just call armv8_pmu_init() directly. > > And as it wasn't clear why they were there in the first place, I went to > look and found this (e424b17) : > > Although nobody uses non-default sysfs attributes today, there's > minimal impact to preserving the notion that maybe, some day, somebody > might, so we may as well keep up appearances. > > It might be worth mentioning that the decision has now been made in the > other way. Sure, will update the commit message to include this. > > >> } >> >> #define PMUV3_INIT_SIMPLE(name) \ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] driver: perf: arm_pmu: Drop some unused arguments from armv8_pmu_init() 2023-10-09 9:17 ` James Clark 2023-10-10 2:36 ` Anshuman Khandual @ 2023-10-10 11:59 ` Robin Murphy 2023-10-12 11:11 ` Anshuman Khandual 1 sibling, 1 reply; 5+ messages in thread From: Robin Murphy @ 2023-10-10 11:59 UTC (permalink / raw) To: James Clark, Anshuman Khandual, linux-arm-kernel Cc: Will Deacon, Mark Rutland, linux-kernel On 09/10/2023 10:17 am, James Clark wrote: > > > On 09/10/2023 04:56, Anshuman Khandual wrote: >> There is just a single call site remaining for armv8_pmu_init(), passing on >> NULL pointers for all custom 'struct attribute_group'. These arguments are >> not really getting used and hence can just be dropped off, thus simplifying >> the code further. >> >> 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 | 17 +++++------------ >> 1 file changed, 5 insertions(+), 12 deletions(-) >> >> diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c >> index 8fcaa26f0f8a..fe4db1831662 100644 >> --- a/drivers/perf/arm_pmuv3.c >> +++ b/drivers/perf/arm_pmuv3.c >> @@ -1187,10 +1187,7 @@ static void armv8_pmu_register_sysctl_table(void) >> } >> >> static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, >> - int (*map_event)(struct perf_event *event), >> - const struct attribute_group *events, >> - const struct attribute_group *format, >> - const struct attribute_group *caps) >> + int (*map_event)(struct perf_event *event)) >> { >> int ret = armv8pmu_probe_pmu(cpu_pmu); >> if (ret) >> @@ -1212,13 +1209,9 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, >> >> cpu_pmu->name = name; >> cpu_pmu->map_event = map_event; >> - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = events ? >> - events : &armv8_pmuv3_events_attr_group; >> - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = format ? >> - format : &armv8_pmuv3_format_attr_group; >> - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_CAPS] = caps ? >> - caps : &armv8_pmuv3_caps_attr_group; >> - >> + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = &armv8_pmuv3_events_attr_group; >> + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = &armv8_pmuv3_format_attr_group; >> + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_CAPS] = &armv8_pmuv3_caps_attr_group; >> armv8_pmu_register_sysctl_table(); >> return 0; >> } >> @@ -1226,7 +1219,7 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, >> static int armv8_pmu_init_nogroups(struct arm_pmu *cpu_pmu, char *name, >> int (*map_event)(struct perf_event *event)) >> { >> - return armv8_pmu_init(cpu_pmu, name, map_event, NULL, NULL, NULL); >> + return armv8_pmu_init(cpu_pmu, name, map_event); > > I think the whole point of the nogroups wrapper was to add the NULLs. If > you remove them, then you can remove the nogroups function too and just > call armv8_pmu_init() directly instead. Indeed the "nogroups" wrapper is entirely meaningless if the callee no longer accepts groups anyway. > And as it wasn't clear why they were there in the first place, I went to > look and found this (e424b17) : > > Although nobody uses non-default sysfs attributes today, there's > minimal impact to preserving the notion that maybe, some day, somebody > might, so we may as well keep up appearances. > > It might be worth mentioning that the decision has now been made in the > other way. Right, the intent at the time was very much just a cosmetic cleanup to help readability and simplify adding new PMU names, and rather deliberately stepping around the question of making material changes to the interface itself. If we've reached the point where we're happy to agree that consistency with the PMUv2 code is no longer helpful to continuing development of the PMUv3 code, then *that* would be the fundamental point of this change. Thanks, Robin. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] driver: perf: arm_pmu: Drop some unused arguments from armv8_pmu_init() 2023-10-10 11:59 ` Robin Murphy @ 2023-10-12 11:11 ` Anshuman Khandual 0 siblings, 0 replies; 5+ messages in thread From: Anshuman Khandual @ 2023-10-12 11:11 UTC (permalink / raw) To: Robin Murphy, James Clark, linux-arm-kernel Cc: Will Deacon, Mark Rutland, linux-kernel On 10/10/23 17:29, Robin Murphy wrote: > On 09/10/2023 10:17 am, James Clark wrote: >> >> >> On 09/10/2023 04:56, Anshuman Khandual wrote: >>> There is just a single call site remaining for armv8_pmu_init(), passing on >>> NULL pointers for all custom 'struct attribute_group'. These arguments are >>> not really getting used and hence can just be dropped off, thus simplifying >>> the code further. >>> >>> 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 | 17 +++++------------ >>> 1 file changed, 5 insertions(+), 12 deletions(-) >>> >>> diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c >>> index 8fcaa26f0f8a..fe4db1831662 100644 >>> --- a/drivers/perf/arm_pmuv3.c >>> +++ b/drivers/perf/arm_pmuv3.c >>> @@ -1187,10 +1187,7 @@ static void armv8_pmu_register_sysctl_table(void) >>> } >>> static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, >>> - int (*map_event)(struct perf_event *event), >>> - const struct attribute_group *events, >>> - const struct attribute_group *format, >>> - const struct attribute_group *caps) >>> + int (*map_event)(struct perf_event *event)) >>> { >>> int ret = armv8pmu_probe_pmu(cpu_pmu); >>> if (ret) >>> @@ -1212,13 +1209,9 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, >>> cpu_pmu->name = name; >>> cpu_pmu->map_event = map_event; >>> - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = events ? >>> - events : &armv8_pmuv3_events_attr_group; >>> - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = format ? >>> - format : &armv8_pmuv3_format_attr_group; >>> - cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_CAPS] = caps ? >>> - caps : &armv8_pmuv3_caps_attr_group; >>> - >>> + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = &armv8_pmuv3_events_attr_group; >>> + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = &armv8_pmuv3_format_attr_group; >>> + cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_CAPS] = &armv8_pmuv3_caps_attr_group; >>> armv8_pmu_register_sysctl_table(); >>> return 0; >>> } >>> @@ -1226,7 +1219,7 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name, >>> static int armv8_pmu_init_nogroups(struct arm_pmu *cpu_pmu, char *name, >>> int (*map_event)(struct perf_event *event)) >>> { >>> - return armv8_pmu_init(cpu_pmu, name, map_event, NULL, NULL, NULL); >>> + return armv8_pmu_init(cpu_pmu, name, map_event); >> >> I think the whole point of the nogroups wrapper was to add the NULLs. If >> you remove them, then you can remove the nogroups function too and just >> call armv8_pmu_init() directly instead. > > Indeed the "nogroups" wrapper is entirely meaningless if the callee no longer accepts groups anyway. > >> And as it wasn't clear why they were there in the first place, I went to >> look and found this (e424b17) : >> >> Although nobody uses non-default sysfs attributes today, there's >> minimal impact to preserving the notion that maybe, some day, somebody >> might, so we may as well keep up appearances. >> >> It might be worth mentioning that the decision has now been made in the >> other way. > > Right, the intent at the time was very much just a cosmetic cleanup to help readability and simplify adding new PMU names, and rather deliberately stepping around the question of making material changes to the interface itself. If we've reached the point where we're happy to agree that consistency with the PMUv2 code is no longer helpful to continuing development of the PMUv3 code, then *that* would be the fundamental point of this change. Does the following commit message sound complete after dropping off the armv8_pmu_init_nogroups() helper as well. driver: perf: arm_pmuv3: Drop some unused arguments from armv8_pmu_init() There is just a single call site remaining for armv8_pmu_init(), passing on NULL pointers for all custom 'struct attribute_group'. These arguments are not really getting used, and hence can be dropped. Afterwards the function armv8_pmu_init_nogroups() itself becomes redundant and can also be dropped as well. The commit e424b1798526 ("arm64: perf: Refactor PMU init callbacks") wanted to preserve the notion that non-default sysfs attributes could be used some time in the future and hence armv8_pmu_init_nogroups() stayed on but now it can be dropped to remove some redundant indirection, simplifying the code. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-10-12 11:11 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-10-09 3:56 [PATCH] driver: perf: arm_pmu: Drop some unused arguments from armv8_pmu_init() Anshuman Khandual 2023-10-09 9:17 ` James Clark 2023-10-10 2:36 ` Anshuman Khandual 2023-10-10 11:59 ` Robin Murphy 2023-10-12 11:11 ` Anshuman Khandual
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®