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/[email protected]/
Changes since v2:
- Add _func parameter in common marcro, so string can be determined by driver.
- Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/
Changes since v1:
- +CC maintainers of each PMU driver.
- Link: https://lore.kernel.org/linux-arm-kernel/[email protected]/
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
Use common macro PMU_EVENT_ATTR_ID to simplify ARMV8_EVENT_ATTR
Cc: Peter Zijlstra <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Will Deacon <[email protected]>
Signed-off-by: Qi Liu <[email protected]>
---
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
Use common macro PMU_EVENT_ATTR_ID to simplify XGENE_PMU_EVENT_ATTR
Cc: Khuong Dinh <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Mark Rutland <[email protected]>
Signed-off-by: Qi Liu <[email protected]>
---
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
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 <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Signed-off-by: Qi Liu <[email protected]>
---
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
Use common macro PMU_EVENT_ATTR_ID to simplify IMX8_DDR_PMU_EVENT_ATTR
Cc: Frank Li <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Mark Rutland <[email protected]>
Reviewed by Frank Li <Frank [email protected]>
Signed-off-by: Qi Liu <[email protected]>
---
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
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/[email protected]/
>
> [...]
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