* [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes
@ 2021-06-09 6:40 Qi Liu
2021-06-09 6:40 ` [PATCH v4 1/7] perf: Add EVENT_ATTR_ID " Qi Liu
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Qi Liu @ 2021-06-09 6:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, will; +Cc: linuxarm
This patchset applies a general EVENT_ATTR_ID to simplify event
attributes in many PMU drivers.
Changes since v3:
- Drop changes in arm_dsu_pmu.c and hisi_uncore_pmu.c.
- Link: https://lore.kernel.org/linux-arm-kernel/1623123201-45634-1-git-send-email-liuqi115@huawei.com/
Changes since v2:
- Add _func parameter in common marcro, so string can be determined by driver.
- Link: https://lore.kernel.org/linux-arm-kernel/1621417919-6632-1-git-send-email-liuqi115@huawei.com/
Changes since v1:
- +CC maintainers of each PMU driver.
- Link: https://lore.kernel.org/linux-arm-kernel/1621322628-9945-1-git-send-email-liuqi115@huawei.com/
Qi Liu (7):
perf: Add EVENT_ATTR_ID to simplify event attributes
drivers/perf: Simplify EVENT ATTR macro in SMMU PMU driver
drivers/perf: Simplify EVENT ATTR macro in qcom_l2_pmu.c
drivers/perf: Simplify EVENT ATTR macro in qcom_l3_pmu.c
drivers/perf: Simplify EVENT ATTR macro in xgene_pmu.c
drivers/perf: Simplify EVENT ATTR macro in fsl_imx8_ddr_perf.c
arm64: perf: Simplify EVENT ATTR macro in perf_event.c
arch/arm64/kernel/perf_event.c | 5 +----
drivers/perf/arm_smmuv3_pmu.c | 7 ++-----
drivers/perf/fsl_imx8_ddr_perf.c | 7 ++-----
drivers/perf/qcom_l2_pmu.c | 7 ++-----
drivers/perf/qcom_l3_pmu.c | 5 +----
drivers/perf/xgene_pmu.c | 11 ++++-------
include/linux/perf_event.h | 6 ++++++
7 files changed, 18 insertions(+), 30 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4 1/7] perf: Add EVENT_ATTR_ID to simplify event attributes
2021-06-09 6:40 [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Qi Liu
@ 2021-06-09 6:40 ` Qi Liu
2021-06-09 6:40 ` [PATCH v4 2/7] drivers/perf: Simplify EVENT ATTR macro in SMMU PMU driver Qi Liu
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Qi Liu @ 2021-06-09 6:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, will
Cc: linuxarm, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin
Similar EVENT_ATTR macros are defined in many PMU drivers,
like Arm PMU driver, Arm SMMU PMU driver. So add a generic
macro to simplify code.
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Qi Liu <liuqi115@huawei.com>
---
include/linux/perf_event.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index f5a6a2f..2d510ad 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -1576,6 +1576,12 @@ static struct perf_pmu_events_attr _var = { \
.event_str = _str, \
};
+#define PMU_EVENT_ATTR_ID(_name, _show, _id) \
+ (&((struct perf_pmu_events_attr[]) { \
+ { .attr = __ATTR(_name, 0444, _show, NULL), \
+ .id = _id, } \
+ })[0].attr.attr)
+
#define PMU_FORMAT_ATTR(_name, _format) \
static ssize_t \
_name##_show(struct device *dev, \
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 2/7] drivers/perf: Simplify EVENT ATTR macro in SMMU PMU driver
2021-06-09 6:40 [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Qi Liu
2021-06-09 6:40 ` [PATCH v4 1/7] perf: Add EVENT_ATTR_ID " Qi Liu
@ 2021-06-09 6:40 ` Qi Liu
2021-06-09 6:40 ` [PATCH v4 3/7] drivers/perf: Simplify EVENT ATTR macro in qcom_l2_pmu.c Qi Liu
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Qi Liu @ 2021-06-09 6:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, will; +Cc: linuxarm, Mark Rutland
Use common macro PMU_EVENT_ATTR_ID to simplify SMMU_EVENT_ATTR
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Qi Liu <liuqi115@huawei.com>
---
drivers/perf/arm_smmuv3_pmu.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c
index 7786ccc..d944835 100644
--- a/drivers/perf/arm_smmuv3_pmu.c
+++ b/drivers/perf/arm_smmuv3_pmu.c
@@ -509,11 +509,8 @@ static ssize_t smmu_pmu_event_show(struct device *dev,
return sysfs_emit(page, "event=0x%02llx\n", pmu_attr->id);
}
-#define SMMU_EVENT_ATTR(name, config) \
- (&((struct perf_pmu_events_attr) { \
- .attr = __ATTR(name, 0444, smmu_pmu_event_show, NULL), \
- .id = config, \
- }).attr.attr)
+#define SMMU_EVENT_ATTR(name, config) \
+ PMU_EVENT_ATTR_ID(name, smmu_pmu_event_show, config)
static struct attribute *smmu_pmu_events[] = {
SMMU_EVENT_ATTR(cycles, 0),
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 3/7] drivers/perf: Simplify EVENT ATTR macro in qcom_l2_pmu.c
2021-06-09 6:40 [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Qi Liu
2021-06-09 6:40 ` [PATCH v4 1/7] perf: Add EVENT_ATTR_ID " Qi Liu
2021-06-09 6:40 ` [PATCH v4 2/7] drivers/perf: Simplify EVENT ATTR macro in SMMU PMU driver Qi Liu
@ 2021-06-09 6:40 ` Qi Liu
2021-06-09 6:41 ` [PATCH v4 4/7] drivers/perf: Simplify EVENT ATTR macro in qcom_l3_pmu.c Qi Liu
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Qi Liu @ 2021-06-09 6:40 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, will; +Cc: linuxarm, Andy Gross, Mark Rutland
Use common macro PMU_EVENT_ATTR_ID to simplify L2CACHE_EVENT_ATTR
Cc: Andy Gross <agross@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Qi Liu <liuqi115@huawei.com>
---
drivers/perf/qcom_l2_pmu.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/perf/qcom_l2_pmu.c b/drivers/perf/qcom_l2_pmu.c
index b60e301..5b093ba 100644
--- a/drivers/perf/qcom_l2_pmu.c
+++ b/drivers/perf/qcom_l2_pmu.c
@@ -679,11 +679,8 @@ static ssize_t l2cache_pmu_event_show(struct device *dev,
return sysfs_emit(page, "event=0x%02llx\n", pmu_attr->id);
}
-#define L2CACHE_EVENT_ATTR(_name, _id) \
- (&((struct perf_pmu_events_attr[]) { \
- { .attr = __ATTR(_name, 0444, l2cache_pmu_event_show, NULL), \
- .id = _id, } \
- })[0].attr.attr)
+#define L2CACHE_EVENT_ATTR(_name, _id) \
+ PMU_EVENT_ATTR_ID(_name, l2cache_pmu_event_show, _id)
static struct attribute *l2_cache_pmu_events[] = {
L2CACHE_EVENT_ATTR(cycles, L2_EVENT_CYCLES),
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 4/7] drivers/perf: Simplify EVENT ATTR macro in qcom_l3_pmu.c
2021-06-09 6:40 [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Qi Liu
` (2 preceding siblings ...)
2021-06-09 6:40 ` [PATCH v4 3/7] drivers/perf: Simplify EVENT ATTR macro in qcom_l2_pmu.c Qi Liu
@ 2021-06-09 6:41 ` Qi Liu
2021-06-09 6:41 ` [PATCH v4 5/7] drivers/perf: Simplify EVENT ATTR macro in xgene_pmu.c Qi Liu
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Qi Liu @ 2021-06-09 6:41 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, will; +Cc: linuxarm, Andy Gross, Mark Rutland
Use common macro PMU_EVENT_ATTR_ID to simplify L3CACHE_EVENT_ATTR
Cc: Andy Gross <agross@kernel.org>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Qi Liu <liuqi115@huawei.com>
---
drivers/perf/qcom_l3_pmu.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/perf/qcom_l3_pmu.c b/drivers/perf/qcom_l3_pmu.c
index 0812735..e033d89 100644
--- a/drivers/perf/qcom_l3_pmu.c
+++ b/drivers/perf/qcom_l3_pmu.c
@@ -647,10 +647,7 @@ static ssize_t l3cache_pmu_event_show(struct device *dev,
}
#define L3CACHE_EVENT_ATTR(_name, _id) \
- (&((struct perf_pmu_events_attr[]) { \
- { .attr = __ATTR(_name, 0444, l3cache_pmu_event_show, NULL), \
- .id = _id, } \
- })[0].attr.attr)
+ PMU_EVENT_ATTR_ID(_name, l3cache_pmu_event_show, _id)
static struct attribute *qcom_l3_cache_pmu_events[] = {
L3CACHE_EVENT_ATTR(cycles, L3_EVENT_CYCLES),
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 5/7] drivers/perf: Simplify EVENT ATTR macro in xgene_pmu.c
2021-06-09 6:40 [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Qi Liu
` (3 preceding siblings ...)
2021-06-09 6:41 ` [PATCH v4 4/7] drivers/perf: Simplify EVENT ATTR macro in qcom_l3_pmu.c Qi Liu
@ 2021-06-09 6:41 ` Qi Liu
2021-06-09 6:41 ` [PATCH v4 6/7] drivers/perf: Simplify EVENT ATTR macro in fsl_imx8_ddr_perf.c Qi Liu
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Qi Liu @ 2021-06-09 6:41 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, will; +Cc: linuxarm, Khuong Dinh, Mark Rutland
Use common macro PMU_EVENT_ATTR_ID to simplify XGENE_PMU_EVENT_ATTR
Cc: Khuong Dinh <khuong@os.amperecomputing.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Qi Liu <liuqi115@huawei.com>
---
drivers/perf/xgene_pmu.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c
index 62d9425..2b6d476 100644
--- a/drivers/perf/xgene_pmu.c
+++ b/drivers/perf/xgene_pmu.c
@@ -278,17 +278,14 @@ static const struct attribute_group mc_pmu_v3_format_attr_group = {
static ssize_t xgene_pmu_event_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
- struct dev_ext_attribute *eattr;
+ struct perf_pmu_events_attr *pmu_attr =
+ container_of(attr, struct perf_pmu_events_attr, attr);
- eattr = container_of(attr, struct dev_ext_attribute, attr);
- return sysfs_emit(buf, "config=0x%lx\n", (unsigned long) eattr->var);
+ return sysfs_emit(buf, "config=0x%llx\n", pmu_attr->id);
}
#define XGENE_PMU_EVENT_ATTR(_name, _config) \
- (&((struct dev_ext_attribute[]) { \
- { .attr = __ATTR(_name, S_IRUGO, xgene_pmu_event_show, NULL), \
- .var = (void *) _config, } \
- })[0].attr.attr)
+ PMU_EVENT_ATTR_ID(_name, xgene_pmu_event_show, _config)
static struct attribute *l3c_pmu_events_attrs[] = {
XGENE_PMU_EVENT_ATTR(cycle-count, 0x00),
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 6/7] drivers/perf: Simplify EVENT ATTR macro in fsl_imx8_ddr_perf.c
2021-06-09 6:40 [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Qi Liu
` (4 preceding siblings ...)
2021-06-09 6:41 ` [PATCH v4 5/7] drivers/perf: Simplify EVENT ATTR macro in xgene_pmu.c Qi Liu
@ 2021-06-09 6:41 ` Qi Liu
2021-06-09 6:41 ` [PATCH v4 7/7] arm64: perf: Simplify EVENT ATTR macro in perf_event.c Qi Liu
2021-06-11 16:15 ` [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Will Deacon
7 siblings, 0 replies; 9+ messages in thread
From: Qi Liu @ 2021-06-09 6:41 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, will; +Cc: linuxarm, Frank Li, Mark Rutland
Use common macro PMU_EVENT_ATTR_ID to simplify IMX8_DDR_PMU_EVENT_ATTR
Cc: Frank Li <Frank.li@nxp.com>
Cc: Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Reviewed by Frank Li <Frank .li@nxp.com>
Signed-off-by: Qi Liu <liuqi115@huawei.com>
---
drivers/perf/fsl_imx8_ddr_perf.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c
index df048fe..2a1d787 100644
--- a/drivers/perf/fsl_imx8_ddr_perf.c
+++ b/drivers/perf/fsl_imx8_ddr_perf.c
@@ -222,11 +222,8 @@ ddr_pmu_event_show(struct device *dev, struct device_attribute *attr,
return sysfs_emit(page, "event=0x%02llx\n", pmu_attr->id);
}
-#define IMX8_DDR_PMU_EVENT_ATTR(_name, _id) \
- (&((struct perf_pmu_events_attr[]) { \
- { .attr = __ATTR(_name, 0444, ddr_pmu_event_show, NULL),\
- .id = _id, } \
- })[0].attr.attr)
+#define IMX8_DDR_PMU_EVENT_ATTR(_name, _id) \
+ PMU_EVENT_ATTR_ID(_name, ddr_pmu_event_show, _id)
static struct attribute *ddr_perf_events_attrs[] = {
IMX8_DDR_PMU_EVENT_ATTR(cycles, EVENT_CYCLES_ID),
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 7/7] arm64: perf: Simplify EVENT ATTR macro in perf_event.c
2021-06-09 6:40 [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Qi Liu
` (5 preceding siblings ...)
2021-06-09 6:41 ` [PATCH v4 6/7] drivers/perf: Simplify EVENT ATTR macro in fsl_imx8_ddr_perf.c Qi Liu
@ 2021-06-09 6:41 ` Qi Liu
2021-06-11 16:15 ` [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Will Deacon
7 siblings, 0 replies; 9+ messages in thread
From: Qi Liu @ 2021-06-09 6:41 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, will
Cc: linuxarm, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin
Use common macro PMU_EVENT_ATTR_ID to simplify ARMV8_EVENT_ATTR
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Qi Liu <liuqi115@huawei.com>
---
arch/arm64/kernel/perf_event.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
index a661010..d07788d 100644
--- a/arch/arm64/kernel/perf_event.c
+++ b/arch/arm64/kernel/perf_event.c
@@ -165,10 +165,7 @@ armv8pmu_events_sysfs_show(struct device *dev,
}
#define ARMV8_EVENT_ATTR(name, config) \
- (&((struct perf_pmu_events_attr) { \
- .attr = __ATTR(name, 0444, armv8pmu_events_sysfs_show, NULL), \
- .id = config, \
- }).attr.attr)
+ PMU_EVENT_ATTR_ID(name, armv8pmu_events_sysfs_show, config)
static struct attribute *armv8_pmuv3_event_attrs[] = {
ARMV8_EVENT_ATTR(sw_incr, ARMV8_PMUV3_PERFCTR_SW_INCR),
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes
2021-06-09 6:40 [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Qi Liu
` (6 preceding siblings ...)
2021-06-09 6:41 ` [PATCH v4 7/7] arm64: perf: Simplify EVENT ATTR macro in perf_event.c Qi Liu
@ 2021-06-11 16:15 ` Will Deacon
7 siblings, 0 replies; 9+ messages in thread
From: Will Deacon @ 2021-06-11 16:15 UTC (permalink / raw)
To: linux-arm-kernel, Qi Liu, linux-kernel
Cc: catalin.marinas, kernel-team, Will Deacon, linuxarm
On Wed, 9 Jun 2021 14:40:56 +0800, Qi Liu wrote:
> This patchset applies a general EVENT_ATTR_ID to simplify event
> attributes in many PMU drivers.
>
> Changes since v3:
> - Drop changes in arm_dsu_pmu.c and hisi_uncore_pmu.c.
> - Link: https://lore.kernel.org/linux-arm-kernel/1623123201-45634-1-git-send-email-liuqi115@huawei.com/
>
> [...]
Applied to will (for-next/perf), thanks!
[1/7] perf: Add EVENT_ATTR_ID to simplify event attributes
https://git.kernel.org/will/c/f8e6d24144d1
[2/7] drivers/perf: Simplify EVENT ATTR macro in SMMU PMU driver
https://git.kernel.org/will/c/7ac87a8dfbd9
[3/7] drivers/perf: Simplify EVENT ATTR macro in qcom_l2_pmu.c
https://git.kernel.org/will/c/0bf2d7298842
[4/7] drivers/perf: Simplify EVENT ATTR macro in qcom_l3_pmu.c
https://git.kernel.org/will/c/78b1d3c72070
[5/7] drivers/perf: Simplify EVENT ATTR macro in xgene_pmu.c
https://git.kernel.org/will/c/b323dfe02e56
[6/7] drivers/perf: Simplify EVENT ATTR macro in fsl_imx8_ddr_perf.c
https://git.kernel.org/will/c/773510f4d277
[7/7] arm64: perf: Simplify EVENT ATTR macro in perf_event.c
https://git.kernel.org/will/c/64432f09068a
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-06-11 16:15 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 6:40 [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Qi Liu
2021-06-09 6:40 ` [PATCH v4 1/7] perf: Add EVENT_ATTR_ID " Qi Liu
2021-06-09 6:40 ` [PATCH v4 2/7] drivers/perf: Simplify EVENT ATTR macro in SMMU PMU driver Qi Liu
2021-06-09 6:40 ` [PATCH v4 3/7] drivers/perf: Simplify EVENT ATTR macro in qcom_l2_pmu.c Qi Liu
2021-06-09 6:41 ` [PATCH v4 4/7] drivers/perf: Simplify EVENT ATTR macro in qcom_l3_pmu.c Qi Liu
2021-06-09 6:41 ` [PATCH v4 5/7] drivers/perf: Simplify EVENT ATTR macro in xgene_pmu.c Qi Liu
2021-06-09 6:41 ` [PATCH v4 6/7] drivers/perf: Simplify EVENT ATTR macro in fsl_imx8_ddr_perf.c Qi Liu
2021-06-09 6:41 ` [PATCH v4 7/7] arm64: perf: Simplify EVENT ATTR macro in perf_event.c Qi Liu
2021-06-11 16:15 ` [PATCH v4 0/7] drivers/perf: Use general macro to simplify event attributes Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).