All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] perf: hisi: Extract hisi_pmu_init
@ 2022-05-16 13:16 ` Chen Jun
  0 siblings, 0 replies; 8+ messages in thread
From: Chen Jun @ 2022-05-16 13:16 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, zhangshaokun, will, mark.rutland
  Cc: xuqiang36

Extract the initialization code of hisi_pmu->pmu into a function

Signed-off-by: Chen Jun <chenjun102@huawei.com>
---
 drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c | 16 +---------------
 drivers/perf/hisilicon/hisi_uncore_hha_pmu.c  | 16 +---------------
 drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c  | 16 +---------------
 drivers/perf/hisilicon/hisi_uncore_pa_pmu.c   | 16 +---------------
 drivers/perf/hisilicon/hisi_uncore_pmu.c      | 18 ++++++++++++++++++
 drivers/perf/hisilicon/hisi_uncore_pmu.h      |  2 ++
 drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c | 15 +--------------
 7 files changed, 25 insertions(+), 74 deletions(-)

diff --git a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
index 62299ab5a9be..50d0c0a2f1fe 100644
--- a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
@@ -516,21 +516,7 @@ static int hisi_ddrc_pmu_probe(struct platform_device *pdev)
 				      "hisi_sccl%u_ddrc%u", ddrc_pmu->sccl_id,
 				      ddrc_pmu->index_id);
 
-	ddrc_pmu->pmu = (struct pmu) {
-		.name		= name,
-		.module		= THIS_MODULE,
-		.task_ctx_nr	= perf_invalid_context,
-		.event_init	= hisi_uncore_pmu_event_init,
-		.pmu_enable	= hisi_uncore_pmu_enable,
-		.pmu_disable	= hisi_uncore_pmu_disable,
-		.add		= hisi_uncore_pmu_add,
-		.del		= hisi_uncore_pmu_del,
-		.start		= hisi_uncore_pmu_start,
-		.stop		= hisi_uncore_pmu_stop,
-		.read		= hisi_uncore_pmu_read,
-		.attr_groups	= ddrc_pmu->pmu_events.attr_groups,
-		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
-	};
+	hisi_pmu_init(&ddrc_pmu->pmu, name, ddrc_pmu->pmu_events.attr_groups, THIS_MODULE);
 
 	ret = perf_pmu_register(&ddrc_pmu->pmu, name, -1);
 	if (ret) {
diff --git a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
index 393513150106..13017b3412a5 100644
--- a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
@@ -519,21 +519,7 @@ static int hisi_hha_pmu_probe(struct platform_device *pdev)
 
 	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_hha%u",
 			      hha_pmu->sccl_id, hha_pmu->index_id);
-	hha_pmu->pmu = (struct pmu) {
-		.name		= name,
-		.module		= THIS_MODULE,
-		.task_ctx_nr	= perf_invalid_context,
-		.event_init	= hisi_uncore_pmu_event_init,
-		.pmu_enable	= hisi_uncore_pmu_enable,
-		.pmu_disable	= hisi_uncore_pmu_disable,
-		.add		= hisi_uncore_pmu_add,
-		.del		= hisi_uncore_pmu_del,
-		.start		= hisi_uncore_pmu_start,
-		.stop		= hisi_uncore_pmu_stop,
-		.read		= hisi_uncore_pmu_read,
-		.attr_groups	= hha_pmu->pmu_events.attr_groups,
-		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
-	};
+	hisi_pmu_init(&hha_pmu->pmu, name, hha_pmu->pmu_events.attr_groups, THIS_MODULE);
 
 	ret = perf_pmu_register(&hha_pmu->pmu, name, -1);
 	if (ret) {
diff --git a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
index 560ab964c8b5..2995f3630d49 100644
--- a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
@@ -557,21 +557,7 @@ static int hisi_l3c_pmu_probe(struct platform_device *pdev)
 	 */
 	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_l3c%u",
 			      l3c_pmu->sccl_id, l3c_pmu->ccl_id);
-	l3c_pmu->pmu = (struct pmu) {
-		.name		= name,
-		.module		= THIS_MODULE,
-		.task_ctx_nr	= perf_invalid_context,
-		.event_init	= hisi_uncore_pmu_event_init,
-		.pmu_enable	= hisi_uncore_pmu_enable,
-		.pmu_disable	= hisi_uncore_pmu_disable,
-		.add		= hisi_uncore_pmu_add,
-		.del		= hisi_uncore_pmu_del,
-		.start		= hisi_uncore_pmu_start,
-		.stop		= hisi_uncore_pmu_stop,
-		.read		= hisi_uncore_pmu_read,
-		.attr_groups	= l3c_pmu->pmu_events.attr_groups,
-		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
-	};
+	hisi_pmu_init(&l3c_pmu->pmu, name, l3c_pmu->pmu_events.attr_groups, THIS_MODULE);
 
 	ret = perf_pmu_register(&l3c_pmu->pmu, name, -1);
 	if (ret) {
diff --git a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
index bad99d149172..2103fb5ee7bb 100644
--- a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
@@ -416,21 +416,7 @@ static int hisi_pa_pmu_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	pa_pmu->pmu = (struct pmu) {
-		.module		= THIS_MODULE,
-		.task_ctx_nr	= perf_invalid_context,
-		.event_init	= hisi_uncore_pmu_event_init,
-		.pmu_enable	= hisi_uncore_pmu_enable,
-		.pmu_disable	= hisi_uncore_pmu_disable,
-		.add		= hisi_uncore_pmu_add,
-		.del		= hisi_uncore_pmu_del,
-		.start		= hisi_uncore_pmu_start,
-		.stop		= hisi_uncore_pmu_stop,
-		.read		= hisi_uncore_pmu_read,
-		.attr_groups    = pa_pmu->pmu_events.attr_groups,
-		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
-	};
-
+	hisi_pmu_init(&pa_pmu->pmu, name, pa_pmu->pmu_events.attr_groups, THIS_MODULE);
 	ret = perf_pmu_register(&pa_pmu->pmu, name, -1);
 	if (ret) {
 		dev_err(pa_pmu->dev, "PMU register failed, ret = %d\n", ret);
diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c
index 358e4e284a62..5dd2694dbdf8 100644
--- a/drivers/perf/hisilicon/hisi_uncore_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c
@@ -527,4 +527,22 @@ int hisi_uncore_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
 }
 EXPORT_SYMBOL_GPL(hisi_uncore_pmu_offline_cpu);
 
+void hisi_pmu_init(struct pmu *pmu, const char *name,
+		const struct attribute_group **attr_groups, struct module *module)
+{
+	pmu->name               = name;
+	pmu->module             = module;
+	pmu->task_ctx_nr        = perf_invalid_context;
+	pmu->event_init         = hisi_uncore_pmu_event_init;
+	pmu->pmu_enable         = hisi_uncore_pmu_enable;
+	pmu->pmu_disable        = hisi_uncore_pmu_disable;
+	pmu->add                = hisi_uncore_pmu_add;
+	pmu->del                = hisi_uncore_pmu_del;
+	pmu->start              = hisi_uncore_pmu_start;
+	pmu->stop               = hisi_uncore_pmu_stop;
+	pmu->read               = hisi_uncore_pmu_read;
+	pmu->attr_groups        = attr_groups;
+}
+EXPORT_SYMBOL_GPL(hisi_pmu_init);
+
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.h b/drivers/perf/hisilicon/hisi_uncore_pmu.h
index 7f5841d6f592..6e2523e4aa36 100644
--- a/drivers/perf/hisilicon/hisi_uncore_pmu.h
+++ b/drivers/perf/hisilicon/hisi_uncore_pmu.h
@@ -120,4 +120,6 @@ ssize_t hisi_uncore_pmu_identifier_attr_show(struct device *dev,
 int hisi_uncore_pmu_init_irq(struct hisi_pmu *hisi_pmu,
 			     struct platform_device *pdev);
 
+void hisi_pmu_init(struct pmu *pmu, const char *name,
+		const struct attribute_group **attr_groups, struct module *module);
 #endif /* __HISI_UNCORE_PMU_H__ */
diff --git a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
index 6aedc303ff56..b9c79f17230c 100644
--- a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
@@ -445,20 +445,7 @@ static int hisi_sllc_pmu_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	sllc_pmu->pmu = (struct pmu) {
-		.module		= THIS_MODULE,
-		.task_ctx_nr	= perf_invalid_context,
-		.event_init	= hisi_uncore_pmu_event_init,
-		.pmu_enable	= hisi_uncore_pmu_enable,
-		.pmu_disable	= hisi_uncore_pmu_disable,
-		.add		= hisi_uncore_pmu_add,
-		.del		= hisi_uncore_pmu_del,
-		.start		= hisi_uncore_pmu_start,
-		.stop		= hisi_uncore_pmu_stop,
-		.read		= hisi_uncore_pmu_read,
-		.attr_groups    = sllc_pmu->pmu_events.attr_groups,
-		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
-	};
+	hisi_pmu_init(&sllc_pmu->pmu, name, sllc_pmu->pmu_events.attr_groups, THIS_MODULE);
 
 	ret = perf_pmu_register(&sllc_pmu->pmu, name, -1);
 	if (ret) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 1/1] perf: hisi: Extract hisi_pmu_init
@ 2022-05-16 13:16 ` Chen Jun
  0 siblings, 0 replies; 8+ messages in thread
From: Chen Jun @ 2022-05-16 13:16 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, zhangshaokun, will, mark.rutland
  Cc: xuqiang36

Extract the initialization code of hisi_pmu->pmu into a function

Signed-off-by: Chen Jun <chenjun102@huawei.com>
---
 drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c | 16 +---------------
 drivers/perf/hisilicon/hisi_uncore_hha_pmu.c  | 16 +---------------
 drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c  | 16 +---------------
 drivers/perf/hisilicon/hisi_uncore_pa_pmu.c   | 16 +---------------
 drivers/perf/hisilicon/hisi_uncore_pmu.c      | 18 ++++++++++++++++++
 drivers/perf/hisilicon/hisi_uncore_pmu.h      |  2 ++
 drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c | 15 +--------------
 7 files changed, 25 insertions(+), 74 deletions(-)

diff --git a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
index 62299ab5a9be..50d0c0a2f1fe 100644
--- a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
@@ -516,21 +516,7 @@ static int hisi_ddrc_pmu_probe(struct platform_device *pdev)
 				      "hisi_sccl%u_ddrc%u", ddrc_pmu->sccl_id,
 				      ddrc_pmu->index_id);
 
-	ddrc_pmu->pmu = (struct pmu) {
-		.name		= name,
-		.module		= THIS_MODULE,
-		.task_ctx_nr	= perf_invalid_context,
-		.event_init	= hisi_uncore_pmu_event_init,
-		.pmu_enable	= hisi_uncore_pmu_enable,
-		.pmu_disable	= hisi_uncore_pmu_disable,
-		.add		= hisi_uncore_pmu_add,
-		.del		= hisi_uncore_pmu_del,
-		.start		= hisi_uncore_pmu_start,
-		.stop		= hisi_uncore_pmu_stop,
-		.read		= hisi_uncore_pmu_read,
-		.attr_groups	= ddrc_pmu->pmu_events.attr_groups,
-		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
-	};
+	hisi_pmu_init(&ddrc_pmu->pmu, name, ddrc_pmu->pmu_events.attr_groups, THIS_MODULE);
 
 	ret = perf_pmu_register(&ddrc_pmu->pmu, name, -1);
 	if (ret) {
diff --git a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
index 393513150106..13017b3412a5 100644
--- a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
@@ -519,21 +519,7 @@ static int hisi_hha_pmu_probe(struct platform_device *pdev)
 
 	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_hha%u",
 			      hha_pmu->sccl_id, hha_pmu->index_id);
-	hha_pmu->pmu = (struct pmu) {
-		.name		= name,
-		.module		= THIS_MODULE,
-		.task_ctx_nr	= perf_invalid_context,
-		.event_init	= hisi_uncore_pmu_event_init,
-		.pmu_enable	= hisi_uncore_pmu_enable,
-		.pmu_disable	= hisi_uncore_pmu_disable,
-		.add		= hisi_uncore_pmu_add,
-		.del		= hisi_uncore_pmu_del,
-		.start		= hisi_uncore_pmu_start,
-		.stop		= hisi_uncore_pmu_stop,
-		.read		= hisi_uncore_pmu_read,
-		.attr_groups	= hha_pmu->pmu_events.attr_groups,
-		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
-	};
+	hisi_pmu_init(&hha_pmu->pmu, name, hha_pmu->pmu_events.attr_groups, THIS_MODULE);
 
 	ret = perf_pmu_register(&hha_pmu->pmu, name, -1);
 	if (ret) {
diff --git a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
index 560ab964c8b5..2995f3630d49 100644
--- a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
@@ -557,21 +557,7 @@ static int hisi_l3c_pmu_probe(struct platform_device *pdev)
 	 */
 	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_l3c%u",
 			      l3c_pmu->sccl_id, l3c_pmu->ccl_id);
-	l3c_pmu->pmu = (struct pmu) {
-		.name		= name,
-		.module		= THIS_MODULE,
-		.task_ctx_nr	= perf_invalid_context,
-		.event_init	= hisi_uncore_pmu_event_init,
-		.pmu_enable	= hisi_uncore_pmu_enable,
-		.pmu_disable	= hisi_uncore_pmu_disable,
-		.add		= hisi_uncore_pmu_add,
-		.del		= hisi_uncore_pmu_del,
-		.start		= hisi_uncore_pmu_start,
-		.stop		= hisi_uncore_pmu_stop,
-		.read		= hisi_uncore_pmu_read,
-		.attr_groups	= l3c_pmu->pmu_events.attr_groups,
-		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
-	};
+	hisi_pmu_init(&l3c_pmu->pmu, name, l3c_pmu->pmu_events.attr_groups, THIS_MODULE);
 
 	ret = perf_pmu_register(&l3c_pmu->pmu, name, -1);
 	if (ret) {
diff --git a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
index bad99d149172..2103fb5ee7bb 100644
--- a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
@@ -416,21 +416,7 @@ static int hisi_pa_pmu_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	pa_pmu->pmu = (struct pmu) {
-		.module		= THIS_MODULE,
-		.task_ctx_nr	= perf_invalid_context,
-		.event_init	= hisi_uncore_pmu_event_init,
-		.pmu_enable	= hisi_uncore_pmu_enable,
-		.pmu_disable	= hisi_uncore_pmu_disable,
-		.add		= hisi_uncore_pmu_add,
-		.del		= hisi_uncore_pmu_del,
-		.start		= hisi_uncore_pmu_start,
-		.stop		= hisi_uncore_pmu_stop,
-		.read		= hisi_uncore_pmu_read,
-		.attr_groups    = pa_pmu->pmu_events.attr_groups,
-		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
-	};
-
+	hisi_pmu_init(&pa_pmu->pmu, name, pa_pmu->pmu_events.attr_groups, THIS_MODULE);
 	ret = perf_pmu_register(&pa_pmu->pmu, name, -1);
 	if (ret) {
 		dev_err(pa_pmu->dev, "PMU register failed, ret = %d\n", ret);
diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c
index 358e4e284a62..5dd2694dbdf8 100644
--- a/drivers/perf/hisilicon/hisi_uncore_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c
@@ -527,4 +527,22 @@ int hisi_uncore_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
 }
 EXPORT_SYMBOL_GPL(hisi_uncore_pmu_offline_cpu);
 
+void hisi_pmu_init(struct pmu *pmu, const char *name,
+		const struct attribute_group **attr_groups, struct module *module)
+{
+	pmu->name               = name;
+	pmu->module             = module;
+	pmu->task_ctx_nr        = perf_invalid_context;
+	pmu->event_init         = hisi_uncore_pmu_event_init;
+	pmu->pmu_enable         = hisi_uncore_pmu_enable;
+	pmu->pmu_disable        = hisi_uncore_pmu_disable;
+	pmu->add                = hisi_uncore_pmu_add;
+	pmu->del                = hisi_uncore_pmu_del;
+	pmu->start              = hisi_uncore_pmu_start;
+	pmu->stop               = hisi_uncore_pmu_stop;
+	pmu->read               = hisi_uncore_pmu_read;
+	pmu->attr_groups        = attr_groups;
+}
+EXPORT_SYMBOL_GPL(hisi_pmu_init);
+
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.h b/drivers/perf/hisilicon/hisi_uncore_pmu.h
index 7f5841d6f592..6e2523e4aa36 100644
--- a/drivers/perf/hisilicon/hisi_uncore_pmu.h
+++ b/drivers/perf/hisilicon/hisi_uncore_pmu.h
@@ -120,4 +120,6 @@ ssize_t hisi_uncore_pmu_identifier_attr_show(struct device *dev,
 int hisi_uncore_pmu_init_irq(struct hisi_pmu *hisi_pmu,
 			     struct platform_device *pdev);
 
+void hisi_pmu_init(struct pmu *pmu, const char *name,
+		const struct attribute_group **attr_groups, struct module *module);
 #endif /* __HISI_UNCORE_PMU_H__ */
diff --git a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
index 6aedc303ff56..b9c79f17230c 100644
--- a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
@@ -445,20 +445,7 @@ static int hisi_sllc_pmu_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	sllc_pmu->pmu = (struct pmu) {
-		.module		= THIS_MODULE,
-		.task_ctx_nr	= perf_invalid_context,
-		.event_init	= hisi_uncore_pmu_event_init,
-		.pmu_enable	= hisi_uncore_pmu_enable,
-		.pmu_disable	= hisi_uncore_pmu_disable,
-		.add		= hisi_uncore_pmu_add,
-		.del		= hisi_uncore_pmu_del,
-		.start		= hisi_uncore_pmu_start,
-		.stop		= hisi_uncore_pmu_stop,
-		.read		= hisi_uncore_pmu_read,
-		.attr_groups    = sllc_pmu->pmu_events.attr_groups,
-		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
-	};
+	hisi_pmu_init(&sllc_pmu->pmu, name, sllc_pmu->pmu_events.attr_groups, THIS_MODULE);
 
 	ret = perf_pmu_register(&sllc_pmu->pmu, name, -1);
 	if (ret) {
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] perf: hisi: Extract hisi_pmu_init
  2022-05-16 13:16 ` Chen Jun
@ 2022-05-16 14:30   ` Jonathan Cameron
  -1 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2022-05-16 14:30 UTC (permalink / raw)
  To: Chen Jun
  Cc: linux-kernel, linux-arm-kernel, zhangshaokun, will, mark.rutland,
	xuqiang36, linuxarm

On Mon, 16 May 2022 13:16:01 +0000
Chen Jun <chenjun102@huawei.com> wrote:

> Extract the initialization code of hisi_pmu->pmu into a function
> 
> Signed-off-by: Chen Jun <chenjun102@huawei.com>

Hi Chen Jun,

If you are going to do this (and I think the stats speak for it being
a good idea), then also look at whether the various exports and
header definitions for the callbacks are all needed any more.

I checked just hisi_uncore_pmu_del and that one at least is
private to hisi_uncore_pmu.c after this patch.
With those cleaned up as well the argument for removing this duplication
will be even stronger!

Thanks,

Jonathan

> ---
>  drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c | 16 +---------------
>  drivers/perf/hisilicon/hisi_uncore_hha_pmu.c  | 16 +---------------
>  drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c  | 16 +---------------
>  drivers/perf/hisilicon/hisi_uncore_pa_pmu.c   | 16 +---------------
>  drivers/perf/hisilicon/hisi_uncore_pmu.c      | 18 ++++++++++++++++++
>  drivers/perf/hisilicon/hisi_uncore_pmu.h      |  2 ++
>  drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c | 15 +--------------
>  7 files changed, 25 insertions(+), 74 deletions(-)
> 
> diff --git a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
> index 62299ab5a9be..50d0c0a2f1fe 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
> @@ -516,21 +516,7 @@ static int hisi_ddrc_pmu_probe(struct platform_device *pdev)
>  				      "hisi_sccl%u_ddrc%u", ddrc_pmu->sccl_id,
>  				      ddrc_pmu->index_id);
>  
> -	ddrc_pmu->pmu = (struct pmu) {
> -		.name		= name,
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups	= ddrc_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&ddrc_pmu->pmu, name, ddrc_pmu->pmu_events.attr_groups, THIS_MODULE);
>  
>  	ret = perf_pmu_register(&ddrc_pmu->pmu, name, -1);
>  	if (ret) {
> diff --git a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
> index 393513150106..13017b3412a5 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
> @@ -519,21 +519,7 @@ static int hisi_hha_pmu_probe(struct platform_device *pdev)
>  
>  	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_hha%u",
>  			      hha_pmu->sccl_id, hha_pmu->index_id);
> -	hha_pmu->pmu = (struct pmu) {
> -		.name		= name,
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups	= hha_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&hha_pmu->pmu, name, hha_pmu->pmu_events.attr_groups, THIS_MODULE);
>  
>  	ret = perf_pmu_register(&hha_pmu->pmu, name, -1);
>  	if (ret) {
> diff --git a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> index 560ab964c8b5..2995f3630d49 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> @@ -557,21 +557,7 @@ static int hisi_l3c_pmu_probe(struct platform_device *pdev)
>  	 */
>  	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_l3c%u",
>  			      l3c_pmu->sccl_id, l3c_pmu->ccl_id);
> -	l3c_pmu->pmu = (struct pmu) {
> -		.name		= name,
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups	= l3c_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&l3c_pmu->pmu, name, l3c_pmu->pmu_events.attr_groups, THIS_MODULE);
>  
>  	ret = perf_pmu_register(&l3c_pmu->pmu, name, -1);
>  	if (ret) {
> diff --git a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
> index bad99d149172..2103fb5ee7bb 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
> @@ -416,21 +416,7 @@ static int hisi_pa_pmu_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> -	pa_pmu->pmu = (struct pmu) {
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups    = pa_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> -
> +	hisi_pmu_init(&pa_pmu->pmu, name, pa_pmu->pmu_events.attr_groups, THIS_MODULE);
>  	ret = perf_pmu_register(&pa_pmu->pmu, name, -1);
>  	if (ret) {
>  		dev_err(pa_pmu->dev, "PMU register failed, ret = %d\n", ret);
> diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c
> index 358e4e284a62..5dd2694dbdf8 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c
> @@ -527,4 +527,22 @@ int hisi_uncore_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
>  }
>  EXPORT_SYMBOL_GPL(hisi_uncore_pmu_offline_cpu);
>  
> +void hisi_pmu_init(struct pmu *pmu, const char *name,
> +		const struct attribute_group **attr_groups, struct module *module)
> +{
> +	pmu->name               = name;
> +	pmu->module             = module;
> +	pmu->task_ctx_nr        = perf_invalid_context;
> +	pmu->event_init         = hisi_uncore_pmu_event_init;
> +	pmu->pmu_enable         = hisi_uncore_pmu_enable;
> +	pmu->pmu_disable        = hisi_uncore_pmu_disable;
> +	pmu->add                = hisi_uncore_pmu_add;
> +	pmu->del                = hisi_uncore_pmu_del;
> +	pmu->start              = hisi_uncore_pmu_start;
> +	pmu->stop               = hisi_uncore_pmu_stop;
> +	pmu->read               = hisi_uncore_pmu_read;
> +	pmu->attr_groups        = attr_groups;
> +}
> +EXPORT_SYMBOL_GPL(hisi_pmu_init);
> +
>  MODULE_LICENSE("GPL v2");
> diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.h b/drivers/perf/hisilicon/hisi_uncore_pmu.h
> index 7f5841d6f592..6e2523e4aa36 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_pmu.h
> +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.h
> @@ -120,4 +120,6 @@ ssize_t hisi_uncore_pmu_identifier_attr_show(struct device *dev,
>  int hisi_uncore_pmu_init_irq(struct hisi_pmu *hisi_pmu,
>  			     struct platform_device *pdev);
>  
> +void hisi_pmu_init(struct pmu *pmu, const char *name,
> +		const struct attribute_group **attr_groups, struct module *module);
>  #endif /* __HISI_UNCORE_PMU_H__ */
> diff --git a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
> index 6aedc303ff56..b9c79f17230c 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
> @@ -445,20 +445,7 @@ static int hisi_sllc_pmu_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> -	sllc_pmu->pmu = (struct pmu) {
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups    = sllc_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&sllc_pmu->pmu, name, sllc_pmu->pmu_events.attr_groups, THIS_MODULE);
>  
>  	ret = perf_pmu_register(&sllc_pmu->pmu, name, -1);
>  	if (ret) {


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] perf: hisi: Extract hisi_pmu_init
@ 2022-05-16 14:30   ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2022-05-16 14:30 UTC (permalink / raw)
  To: Chen Jun
  Cc: linux-kernel, linux-arm-kernel, zhangshaokun, will, mark.rutland,
	xuqiang36, linuxarm

On Mon, 16 May 2022 13:16:01 +0000
Chen Jun <chenjun102@huawei.com> wrote:

> Extract the initialization code of hisi_pmu->pmu into a function
> 
> Signed-off-by: Chen Jun <chenjun102@huawei.com>

Hi Chen Jun,

If you are going to do this (and I think the stats speak for it being
a good idea), then also look at whether the various exports and
header definitions for the callbacks are all needed any more.

I checked just hisi_uncore_pmu_del and that one at least is
private to hisi_uncore_pmu.c after this patch.
With those cleaned up as well the argument for removing this duplication
will be even stronger!

Thanks,

Jonathan

> ---
>  drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c | 16 +---------------
>  drivers/perf/hisilicon/hisi_uncore_hha_pmu.c  | 16 +---------------
>  drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c  | 16 +---------------
>  drivers/perf/hisilicon/hisi_uncore_pa_pmu.c   | 16 +---------------
>  drivers/perf/hisilicon/hisi_uncore_pmu.c      | 18 ++++++++++++++++++
>  drivers/perf/hisilicon/hisi_uncore_pmu.h      |  2 ++
>  drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c | 15 +--------------
>  7 files changed, 25 insertions(+), 74 deletions(-)
> 
> diff --git a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
> index 62299ab5a9be..50d0c0a2f1fe 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
> @@ -516,21 +516,7 @@ static int hisi_ddrc_pmu_probe(struct platform_device *pdev)
>  				      "hisi_sccl%u_ddrc%u", ddrc_pmu->sccl_id,
>  				      ddrc_pmu->index_id);
>  
> -	ddrc_pmu->pmu = (struct pmu) {
> -		.name		= name,
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups	= ddrc_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&ddrc_pmu->pmu, name, ddrc_pmu->pmu_events.attr_groups, THIS_MODULE);
>  
>  	ret = perf_pmu_register(&ddrc_pmu->pmu, name, -1);
>  	if (ret) {
> diff --git a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
> index 393513150106..13017b3412a5 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
> @@ -519,21 +519,7 @@ static int hisi_hha_pmu_probe(struct platform_device *pdev)
>  
>  	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_hha%u",
>  			      hha_pmu->sccl_id, hha_pmu->index_id);
> -	hha_pmu->pmu = (struct pmu) {
> -		.name		= name,
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups	= hha_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&hha_pmu->pmu, name, hha_pmu->pmu_events.attr_groups, THIS_MODULE);
>  
>  	ret = perf_pmu_register(&hha_pmu->pmu, name, -1);
>  	if (ret) {
> diff --git a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> index 560ab964c8b5..2995f3630d49 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> @@ -557,21 +557,7 @@ static int hisi_l3c_pmu_probe(struct platform_device *pdev)
>  	 */
>  	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_l3c%u",
>  			      l3c_pmu->sccl_id, l3c_pmu->ccl_id);
> -	l3c_pmu->pmu = (struct pmu) {
> -		.name		= name,
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups	= l3c_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&l3c_pmu->pmu, name, l3c_pmu->pmu_events.attr_groups, THIS_MODULE);
>  
>  	ret = perf_pmu_register(&l3c_pmu->pmu, name, -1);
>  	if (ret) {
> diff --git a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
> index bad99d149172..2103fb5ee7bb 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
> @@ -416,21 +416,7 @@ static int hisi_pa_pmu_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> -	pa_pmu->pmu = (struct pmu) {
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups    = pa_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> -
> +	hisi_pmu_init(&pa_pmu->pmu, name, pa_pmu->pmu_events.attr_groups, THIS_MODULE);
>  	ret = perf_pmu_register(&pa_pmu->pmu, name, -1);
>  	if (ret) {
>  		dev_err(pa_pmu->dev, "PMU register failed, ret = %d\n", ret);
> diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c
> index 358e4e284a62..5dd2694dbdf8 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c
> @@ -527,4 +527,22 @@ int hisi_uncore_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
>  }
>  EXPORT_SYMBOL_GPL(hisi_uncore_pmu_offline_cpu);
>  
> +void hisi_pmu_init(struct pmu *pmu, const char *name,
> +		const struct attribute_group **attr_groups, struct module *module)
> +{
> +	pmu->name               = name;
> +	pmu->module             = module;
> +	pmu->task_ctx_nr        = perf_invalid_context;
> +	pmu->event_init         = hisi_uncore_pmu_event_init;
> +	pmu->pmu_enable         = hisi_uncore_pmu_enable;
> +	pmu->pmu_disable        = hisi_uncore_pmu_disable;
> +	pmu->add                = hisi_uncore_pmu_add;
> +	pmu->del                = hisi_uncore_pmu_del;
> +	pmu->start              = hisi_uncore_pmu_start;
> +	pmu->stop               = hisi_uncore_pmu_stop;
> +	pmu->read               = hisi_uncore_pmu_read;
> +	pmu->attr_groups        = attr_groups;
> +}
> +EXPORT_SYMBOL_GPL(hisi_pmu_init);
> +
>  MODULE_LICENSE("GPL v2");
> diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.h b/drivers/perf/hisilicon/hisi_uncore_pmu.h
> index 7f5841d6f592..6e2523e4aa36 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_pmu.h
> +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.h
> @@ -120,4 +120,6 @@ ssize_t hisi_uncore_pmu_identifier_attr_show(struct device *dev,
>  int hisi_uncore_pmu_init_irq(struct hisi_pmu *hisi_pmu,
>  			     struct platform_device *pdev);
>  
> +void hisi_pmu_init(struct pmu *pmu, const char *name,
> +		const struct attribute_group **attr_groups, struct module *module);
>  #endif /* __HISI_UNCORE_PMU_H__ */
> diff --git a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
> index 6aedc303ff56..b9c79f17230c 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
> @@ -445,20 +445,7 @@ static int hisi_sllc_pmu_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> -	sllc_pmu->pmu = (struct pmu) {
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups    = sllc_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&sllc_pmu->pmu, name, sllc_pmu->pmu_events.attr_groups, THIS_MODULE);
>  
>  	ret = perf_pmu_register(&sllc_pmu->pmu, name, -1);
>  	if (ret) {


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] perf: hisi: Extract hisi_pmu_init
  2022-05-16 13:16 ` Chen Jun
@ 2022-05-16 15:32   ` John Garry
  -1 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2022-05-16 15:32 UTC (permalink / raw)
  To: Chen Jun, linux-kernel, linux-arm-kernel, zhangshaokun, will,
	mark.rutland
  Cc: xuqiang36

On 16/05/2022 14:16, Chen Jun wrote:
> Extract the initialization code of hisi_pmu->pmu into a function
> 
> Signed-off-by: Chen Jun <chenjun102@huawei.com>
> ---
>   drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c | 16 +---------------
>   drivers/perf/hisilicon/hisi_uncore_hha_pmu.c  | 16 +---------------
>   drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c  | 16 +---------------
>   drivers/perf/hisilicon/hisi_uncore_pa_pmu.c   | 16 +---------------
>   drivers/perf/hisilicon/hisi_uncore_pmu.c      | 18 ++++++++++++++++++
>   drivers/perf/hisilicon/hisi_uncore_pmu.h      |  2 ++
>   drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c | 15 +--------------
>   7 files changed, 25 insertions(+), 74 deletions(-)
> 
> diff --git a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
> index 62299ab5a9be..50d0c0a2f1fe 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
> @@ -516,21 +516,7 @@ static int hisi_ddrc_pmu_probe(struct platform_device *pdev)
>   				      "hisi_sccl%u_ddrc%u", ddrc_pmu->sccl_id,
>   				      ddrc_pmu->index_id);
>   
> -	ddrc_pmu->pmu = (struct pmu) {
> -		.name		= name,
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups	= ddrc_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&ddrc_pmu->pmu, name, ddrc_pmu->pmu_events.attr_groups, THIS_MODULE);
>   
>   	ret = perf_pmu_register(&ddrc_pmu->pmu, name, -1);
>   	if (ret) {
> diff --git a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
> index 393513150106..13017b3412a5 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
> @@ -519,21 +519,7 @@ static int hisi_hha_pmu_probe(struct platform_device *pdev)
>   
>   	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_hha%u",
>   			      hha_pmu->sccl_id, hha_pmu->index_id);
> -	hha_pmu->pmu = (struct pmu) {
> -		.name		= name,
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups	= hha_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&hha_pmu->pmu, name, hha_pmu->pmu_events.attr_groups, THIS_MODULE);
>   
>   	ret = perf_pmu_register(&hha_pmu->pmu, name, -1);
>   	if (ret) {
> diff --git a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> index 560ab964c8b5..2995f3630d49 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> @@ -557,21 +557,7 @@ static int hisi_l3c_pmu_probe(struct platform_device *pdev)
>   	 */
>   	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_l3c%u",
>   			      l3c_pmu->sccl_id, l3c_pmu->ccl_id);
> -	l3c_pmu->pmu = (struct pmu) {
> -		.name		= name,
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups	= l3c_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&l3c_pmu->pmu, name, l3c_pmu->pmu_events.attr_groups, THIS_MODULE);
>   

why not just pass l3c_pmu and extract the info there?

We always seem to be dealing with type struct hisi_pmu * AFAICS.

>   	ret = perf_pmu_register(&l3c_pmu->pmu, name, -1);
>   	if (ret) {
> diff --git a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
> index bad99d149172..2103fb5ee7bb 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
> @@ -416,21 +416,7 @@ static int hisi_pa_pmu_probe(struct platform_device *pdev)
>   		return ret;
>   	}
>   
> -	pa_pmu->pmu = (struct pmu) {
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups    = pa_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> -
> +	hisi_pmu_init(&pa_pmu->pmu, name, pa_pmu->pmu_events.attr_groups, THIS_MODULE);
>   	ret = perf_pmu_register(&pa_pmu->pmu, name, -1);
>   	if (ret) {
>   		dev_err(pa_pmu->dev, "PMU register failed, ret = %d\n", ret);
> diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c
> index 358e4e284a62..5dd2694dbdf8 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c
> @@ -527,4 +527,22 @@ int hisi_uncore_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
>   }
>   EXPORT_SYMBOL_GPL(hisi_uncore_pmu_offline_cpu);
>   
> +void hisi_pmu_init(struct pmu *pmu, const char *name,
> +		const struct attribute_group **attr_groups, struct module *module)
> +{
> +	pmu->name               = name;
> +	pmu->module             = module;
> +	pmu->task_ctx_nr        = perf_invalid_context;
> +	pmu->event_init         = hisi_uncore_pmu_event_init;
> +	pmu->pmu_enable         = hisi_uncore_pmu_enable;
> +	pmu->pmu_disable        = hisi_uncore_pmu_disable;
> +	pmu->add                = hisi_uncore_pmu_add;
> +	pmu->del                = hisi_uncore_pmu_del;
> +	pmu->start              = hisi_uncore_pmu_start;
> +	pmu->stop               = hisi_uncore_pmu_stop;
> +	pmu->read               = hisi_uncore_pmu_read;
> +	pmu->attr_groups        = attr_groups;
> +}
> +EXPORT_SYMBOL_GPL(hisi_pmu_init);
> +
>   MODULE_LICENSE("GPL v2");
> diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.h b/drivers/perf/hisilicon/hisi_uncore_pmu.h
> index 7f5841d6f592..6e2523e4aa36 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_pmu.h
> +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.h
> @@ -120,4 +120,6 @@ ssize_t hisi_uncore_pmu_identifier_attr_show(struct device *dev,
>   int hisi_uncore_pmu_init_irq(struct hisi_pmu *hisi_pmu,
>   			     struct platform_device *pdev);
>   
> +void hisi_pmu_init(struct pmu *pmu, const char *name,
> +		const struct attribute_group **attr_groups, struct module *module);
>   #endif /* __HISI_UNCORE_PMU_H__ */
> diff --git a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
> index 6aedc303ff56..b9c79f17230c 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
> @@ -445,20 +445,7 @@ static int hisi_sllc_pmu_probe(struct platform_device *pdev)
>   		return ret;
>   	}
>   
> -	sllc_pmu->pmu = (struct pmu) {
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups    = sllc_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&sllc_pmu->pmu, name, sllc_pmu->pmu_events.attr_groups, THIS_MODULE);
>   
>   	ret = perf_pmu_register(&sllc_pmu->pmu, name, -1);

why not make hisi_pmu_init() do the perf_pmu_register() call as well?

That seems the common pattern.

>   	if (ret) {


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] perf: hisi: Extract hisi_pmu_init
@ 2022-05-16 15:32   ` John Garry
  0 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2022-05-16 15:32 UTC (permalink / raw)
  To: Chen Jun, linux-kernel, linux-arm-kernel, zhangshaokun, will,
	mark.rutland
  Cc: xuqiang36

On 16/05/2022 14:16, Chen Jun wrote:
> Extract the initialization code of hisi_pmu->pmu into a function
> 
> Signed-off-by: Chen Jun <chenjun102@huawei.com>
> ---
>   drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c | 16 +---------------
>   drivers/perf/hisilicon/hisi_uncore_hha_pmu.c  | 16 +---------------
>   drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c  | 16 +---------------
>   drivers/perf/hisilicon/hisi_uncore_pa_pmu.c   | 16 +---------------
>   drivers/perf/hisilicon/hisi_uncore_pmu.c      | 18 ++++++++++++++++++
>   drivers/perf/hisilicon/hisi_uncore_pmu.h      |  2 ++
>   drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c | 15 +--------------
>   7 files changed, 25 insertions(+), 74 deletions(-)
> 
> diff --git a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
> index 62299ab5a9be..50d0c0a2f1fe 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
> @@ -516,21 +516,7 @@ static int hisi_ddrc_pmu_probe(struct platform_device *pdev)
>   				      "hisi_sccl%u_ddrc%u", ddrc_pmu->sccl_id,
>   				      ddrc_pmu->index_id);
>   
> -	ddrc_pmu->pmu = (struct pmu) {
> -		.name		= name,
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups	= ddrc_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&ddrc_pmu->pmu, name, ddrc_pmu->pmu_events.attr_groups, THIS_MODULE);
>   
>   	ret = perf_pmu_register(&ddrc_pmu->pmu, name, -1);
>   	if (ret) {
> diff --git a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
> index 393513150106..13017b3412a5 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
> @@ -519,21 +519,7 @@ static int hisi_hha_pmu_probe(struct platform_device *pdev)
>   
>   	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_hha%u",
>   			      hha_pmu->sccl_id, hha_pmu->index_id);
> -	hha_pmu->pmu = (struct pmu) {
> -		.name		= name,
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups	= hha_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&hha_pmu->pmu, name, hha_pmu->pmu_events.attr_groups, THIS_MODULE);
>   
>   	ret = perf_pmu_register(&hha_pmu->pmu, name, -1);
>   	if (ret) {
> diff --git a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> index 560ab964c8b5..2995f3630d49 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
> @@ -557,21 +557,7 @@ static int hisi_l3c_pmu_probe(struct platform_device *pdev)
>   	 */
>   	name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "hisi_sccl%u_l3c%u",
>   			      l3c_pmu->sccl_id, l3c_pmu->ccl_id);
> -	l3c_pmu->pmu = (struct pmu) {
> -		.name		= name,
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups	= l3c_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&l3c_pmu->pmu, name, l3c_pmu->pmu_events.attr_groups, THIS_MODULE);
>   

why not just pass l3c_pmu and extract the info there?

We always seem to be dealing with type struct hisi_pmu * AFAICS.

>   	ret = perf_pmu_register(&l3c_pmu->pmu, name, -1);
>   	if (ret) {
> diff --git a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
> index bad99d149172..2103fb5ee7bb 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
> @@ -416,21 +416,7 @@ static int hisi_pa_pmu_probe(struct platform_device *pdev)
>   		return ret;
>   	}
>   
> -	pa_pmu->pmu = (struct pmu) {
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups    = pa_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> -
> +	hisi_pmu_init(&pa_pmu->pmu, name, pa_pmu->pmu_events.attr_groups, THIS_MODULE);
>   	ret = perf_pmu_register(&pa_pmu->pmu, name, -1);
>   	if (ret) {
>   		dev_err(pa_pmu->dev, "PMU register failed, ret = %d\n", ret);
> diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pmu.c
> index 358e4e284a62..5dd2694dbdf8 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.c
> @@ -527,4 +527,22 @@ int hisi_uncore_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
>   }
>   EXPORT_SYMBOL_GPL(hisi_uncore_pmu_offline_cpu);
>   
> +void hisi_pmu_init(struct pmu *pmu, const char *name,
> +		const struct attribute_group **attr_groups, struct module *module)
> +{
> +	pmu->name               = name;
> +	pmu->module             = module;
> +	pmu->task_ctx_nr        = perf_invalid_context;
> +	pmu->event_init         = hisi_uncore_pmu_event_init;
> +	pmu->pmu_enable         = hisi_uncore_pmu_enable;
> +	pmu->pmu_disable        = hisi_uncore_pmu_disable;
> +	pmu->add                = hisi_uncore_pmu_add;
> +	pmu->del                = hisi_uncore_pmu_del;
> +	pmu->start              = hisi_uncore_pmu_start;
> +	pmu->stop               = hisi_uncore_pmu_stop;
> +	pmu->read               = hisi_uncore_pmu_read;
> +	pmu->attr_groups        = attr_groups;
> +}
> +EXPORT_SYMBOL_GPL(hisi_pmu_init);
> +
>   MODULE_LICENSE("GPL v2");
> diff --git a/drivers/perf/hisilicon/hisi_uncore_pmu.h b/drivers/perf/hisilicon/hisi_uncore_pmu.h
> index 7f5841d6f592..6e2523e4aa36 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_pmu.h
> +++ b/drivers/perf/hisilicon/hisi_uncore_pmu.h
> @@ -120,4 +120,6 @@ ssize_t hisi_uncore_pmu_identifier_attr_show(struct device *dev,
>   int hisi_uncore_pmu_init_irq(struct hisi_pmu *hisi_pmu,
>   			     struct platform_device *pdev);
>   
> +void hisi_pmu_init(struct pmu *pmu, const char *name,
> +		const struct attribute_group **attr_groups, struct module *module);
>   #endif /* __HISI_UNCORE_PMU_H__ */
> diff --git a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
> index 6aedc303ff56..b9c79f17230c 100644
> --- a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
> +++ b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
> @@ -445,20 +445,7 @@ static int hisi_sllc_pmu_probe(struct platform_device *pdev)
>   		return ret;
>   	}
>   
> -	sllc_pmu->pmu = (struct pmu) {
> -		.module		= THIS_MODULE,
> -		.task_ctx_nr	= perf_invalid_context,
> -		.event_init	= hisi_uncore_pmu_event_init,
> -		.pmu_enable	= hisi_uncore_pmu_enable,
> -		.pmu_disable	= hisi_uncore_pmu_disable,
> -		.add		= hisi_uncore_pmu_add,
> -		.del		= hisi_uncore_pmu_del,
> -		.start		= hisi_uncore_pmu_start,
> -		.stop		= hisi_uncore_pmu_stop,
> -		.read		= hisi_uncore_pmu_read,
> -		.attr_groups    = sllc_pmu->pmu_events.attr_groups,
> -		.capabilities	= PERF_PMU_CAP_NO_EXCLUDE,
> -	};
> +	hisi_pmu_init(&sllc_pmu->pmu, name, sllc_pmu->pmu_events.attr_groups, THIS_MODULE);
>   
>   	ret = perf_pmu_register(&sllc_pmu->pmu, name, -1);

why not make hisi_pmu_init() do the perf_pmu_register() call as well?

That seems the common pattern.

>   	if (ret) {


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] perf: hisi: Extract hisi_pmu_init
  2022-05-16 13:16 ` Chen Jun
@ 2022-06-27 13:00   ` Will Deacon
  -1 siblings, 0 replies; 8+ messages in thread
From: Will Deacon @ 2022-06-27 13:00 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, mark.rutland, zhangshaokun, Chen Jun
  Cc: catalin.marinas, kernel-team, Will Deacon, xuqiang36

On Mon, 16 May 2022 13:16:01 +0000, Chen Jun wrote:
> Extract the initialization code of hisi_pmu->pmu into a function
> 
> 

Applied to will (for-next/perf), thanks!

[1/1] perf: hisi: Extract hisi_pmu_init
      https://git.kernel.org/will/c/e500405dd15d

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/1] perf: hisi: Extract hisi_pmu_init
@ 2022-06-27 13:00   ` Will Deacon
  0 siblings, 0 replies; 8+ messages in thread
From: Will Deacon @ 2022-06-27 13:00 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, mark.rutland, zhangshaokun, Chen Jun
  Cc: catalin.marinas, kernel-team, Will Deacon, xuqiang36

On Mon, 16 May 2022 13:16:01 +0000, Chen Jun wrote:
> Extract the initialization code of hisi_pmu->pmu into a function
> 
> 

Applied to will (for-next/perf), thanks!

[1/1] perf: hisi: Extract hisi_pmu_init
      https://git.kernel.org/will/c/e500405dd15d

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-06-27 13:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16 13:16 [PATCH 1/1] perf: hisi: Extract hisi_pmu_init Chen Jun
2022-05-16 13:16 ` Chen Jun
2022-05-16 14:30 ` Jonathan Cameron
2022-05-16 14:30   ` Jonathan Cameron
2022-05-16 15:32 ` John Garry
2022-05-16 15:32   ` John Garry
2022-06-27 13:00 ` Will Deacon
2022-06-27 13:00   ` Will Deacon

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.