From: Mark Rutland <mark.rutland@arm.com> To: Robin Murphy <robin.murphy@arm.com> Cc: will@kernel.org, catalin.marinas@arm.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 4/5] arm64: perf: Refactor PMU init callbacks Date: Fri, 28 Feb 2020 12:15:34 +0000 [thread overview] Message-ID: <20200228121534.GE36089@lakrids.cambridge.arm.com> (raw) In-Reply-To: <acd2f12447f8ca2fdfe2b161fc41dc84fee90471.1582312530.git.robin.murphy@arm.com> On Fri, Feb 21, 2020 at 07:35:31PM +0000, Robin Murphy wrote: > The PMU init callbacks are already drowning in boilerplate, so before > doubling the number of supported PMU models, give it a sensible refactor > to significantly reduce the bloat, both in source and object code. > 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. > > Signed-off-by: Robin Murphy <robin.murphy@arm.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Mark. > --- > > v2: new > > arch/arm64/kernel/perf_event.c | 124 +++++++-------------------------- > 1 file changed, 27 insertions(+), 97 deletions(-) > > diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c > index e40b65645c86..1e0b04da2f3a 100644 > --- a/arch/arm64/kernel/perf_event.c > +++ b/arch/arm64/kernel/perf_event.c > @@ -953,7 +953,10 @@ static int armv8pmu_probe_pmu(struct arm_pmu *cpu_pmu) > return probe.present ? 0 : -ENODEV; > } > > -static int armv8_pmu_init(struct arm_pmu *cpu_pmu) > +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) > { > int ret = armv8pmu_probe_pmu(cpu_pmu); > if (ret) > @@ -972,135 +975,62 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu) > cpu_pmu->set_event_filter = armv8pmu_set_event_filter; > cpu_pmu->filter_match = armv8pmu_filter_match; > > + 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; > + > return 0; > } > > static int armv8_pmuv3_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_pmuv3"; > - cpu_pmu->map_event = armv8_pmuv3_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_pmuv3", > + armv8_pmuv3_map_event, NULL, NULL); > } > > static int armv8_a35_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_cortex_a35"; > - cpu_pmu->map_event = armv8_a53_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_cortex_a35", > + armv8_a53_map_event, NULL, NULL); > } > > static int armv8_a53_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_cortex_a53"; > - cpu_pmu->map_event = armv8_a53_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_cortex_a53", > + armv8_a53_map_event, NULL, NULL); > } > > static int armv8_a57_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_cortex_a57"; > - cpu_pmu->map_event = armv8_a57_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_cortex_a57", > + armv8_a57_map_event, NULL, NULL); > } > > static int armv8_a72_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_cortex_a72"; > - cpu_pmu->map_event = armv8_a57_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_cortex_a72", > + armv8_a57_map_event, NULL, NULL); > } > > static int armv8_a73_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_cortex_a73"; > - cpu_pmu->map_event = armv8_a73_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_cortex_a73", > + armv8_a73_map_event, NULL, NULL); > } > > static int armv8_thunder_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_cavium_thunder"; > - cpu_pmu->map_event = armv8_thunder_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_cavium_thunder", > + armv8_thunder_map_event, NULL, NULL); > } > > static int armv8_vulcan_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_brcm_vulcan"; > - cpu_pmu->map_event = armv8_vulcan_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_brcm_vulcan", > + armv8_vulcan_map_event, NULL, NULL); > } > > static const struct of_device_id armv8_pmu_of_device_ids[] = { > -- > 2.23.0.dirty >
WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com> To: Robin Murphy <robin.murphy@arm.com> Cc: catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: Re: [PATCH v2 4/5] arm64: perf: Refactor PMU init callbacks Date: Fri, 28 Feb 2020 12:15:34 +0000 [thread overview] Message-ID: <20200228121534.GE36089@lakrids.cambridge.arm.com> (raw) In-Reply-To: <acd2f12447f8ca2fdfe2b161fc41dc84fee90471.1582312530.git.robin.murphy@arm.com> On Fri, Feb 21, 2020 at 07:35:31PM +0000, Robin Murphy wrote: > The PMU init callbacks are already drowning in boilerplate, so before > doubling the number of supported PMU models, give it a sensible refactor > to significantly reduce the bloat, both in source and object code. > 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. > > Signed-off-by: Robin Murphy <robin.murphy@arm.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Mark. > --- > > v2: new > > arch/arm64/kernel/perf_event.c | 124 +++++++-------------------------- > 1 file changed, 27 insertions(+), 97 deletions(-) > > diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c > index e40b65645c86..1e0b04da2f3a 100644 > --- a/arch/arm64/kernel/perf_event.c > +++ b/arch/arm64/kernel/perf_event.c > @@ -953,7 +953,10 @@ static int armv8pmu_probe_pmu(struct arm_pmu *cpu_pmu) > return probe.present ? 0 : -ENODEV; > } > > -static int armv8_pmu_init(struct arm_pmu *cpu_pmu) > +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) > { > int ret = armv8pmu_probe_pmu(cpu_pmu); > if (ret) > @@ -972,135 +975,62 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu) > cpu_pmu->set_event_filter = armv8pmu_set_event_filter; > cpu_pmu->filter_match = armv8pmu_filter_match; > > + 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; > + > return 0; > } > > static int armv8_pmuv3_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_pmuv3"; > - cpu_pmu->map_event = armv8_pmuv3_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_pmuv3", > + armv8_pmuv3_map_event, NULL, NULL); > } > > static int armv8_a35_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_cortex_a35"; > - cpu_pmu->map_event = armv8_a53_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_cortex_a35", > + armv8_a53_map_event, NULL, NULL); > } > > static int armv8_a53_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_cortex_a53"; > - cpu_pmu->map_event = armv8_a53_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_cortex_a53", > + armv8_a53_map_event, NULL, NULL); > } > > static int armv8_a57_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_cortex_a57"; > - cpu_pmu->map_event = armv8_a57_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_cortex_a57", > + armv8_a57_map_event, NULL, NULL); > } > > static int armv8_a72_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_cortex_a72"; > - cpu_pmu->map_event = armv8_a57_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_cortex_a72", > + armv8_a57_map_event, NULL, NULL); > } > > static int armv8_a73_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_cortex_a73"; > - cpu_pmu->map_event = armv8_a73_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_cortex_a73", > + armv8_a73_map_event, NULL, NULL); > } > > static int armv8_thunder_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_cavium_thunder"; > - cpu_pmu->map_event = armv8_thunder_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_cavium_thunder", > + armv8_thunder_map_event, NULL, NULL); > } > > static int armv8_vulcan_pmu_init(struct arm_pmu *cpu_pmu) > { > - int ret = armv8_pmu_init(cpu_pmu); > - if (ret) > - return ret; > - > - cpu_pmu->name = "armv8_brcm_vulcan"; > - cpu_pmu->map_event = armv8_vulcan_map_event; > - 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; > - > - return 0; > + return armv8_pmu_init(cpu_pmu, "armv8_brcm_vulcan", > + armv8_vulcan_map_event, NULL, NULL); > } > > static const struct of_device_id armv8_pmu_of_device_ids[] = { > -- > 2.23.0.dirty > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-02-28 12:15 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-02-21 19:35 [PATCH v2 0/5] arm64 CPU DT binding updates Robin Murphy 2020-02-21 19:35 ` Robin Murphy 2020-02-21 19:35 ` [PATCH v2 1/5] dt-bindings: ARM: Add recent Cortex/Neoverse CPUs Robin Murphy 2020-02-21 19:35 ` Robin Murphy 2020-02-25 19:00 ` Rob Herring 2020-02-25 19:00 ` Rob Herring 2020-02-21 19:35 ` [PATCH v2 2/5] dt-bindings: ARM: Add recent Cortex/Neoverse PMUs Robin Murphy 2020-02-21 19:35 ` Robin Murphy 2020-02-25 19:00 ` Rob Herring 2020-02-25 19:00 ` Rob Herring 2020-02-21 19:35 ` [PATCH v2 3/5] dt-bindings: ARM: Clean up PMU compatible list Robin Murphy 2020-02-21 19:35 ` Robin Murphy 2020-02-25 19:01 ` Rob Herring 2020-02-25 19:01 ` Rob Herring 2020-02-21 19:35 ` [PATCH v2 4/5] arm64: perf: Refactor PMU init callbacks Robin Murphy 2020-02-21 19:35 ` Robin Murphy 2020-02-28 12:15 ` Mark Rutland [this message] 2020-02-28 12:15 ` Mark Rutland 2020-02-21 19:35 ` [PATCH v2 5/5] arm64: perf: Support new DT compatibles Robin Murphy 2020-02-21 19:35 ` Robin Murphy 2020-02-28 12:17 ` Mark Rutland 2020-02-28 12:17 ` Mark Rutland 2020-02-28 12:24 ` Will Deacon 2020-02-28 12:24 ` Will Deacon 2020-03-02 11:54 ` Will Deacon 2020-03-02 11:54 ` Will Deacon
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200228121534.GE36089@lakrids.cambridge.arm.com \ --to=mark.rutland@arm.com \ --cc=catalin.marinas@arm.com \ --cc=devicetree@vger.kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=robin.murphy@arm.com \ --cc=will@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.