[PATCH] perf: arm_v7_pmu: suppress -Winitializer-overrides for perf maps

From: Rosen Penev

Date: Tue Nov 10 2026 - 21:33:59 EST


The perf_map and cache_map arrays intentionally use a range initializer
to fill all entries with HW_OP_UNSUPPORTED / CACHE_OP_UNSUPPORTED, then
override specific entries with supported event codes. This is valid C99
designated initializer behavior (last initializer wins), but Clang's
-Winitializer-overrides warns about each overridden entry.

Suppress the warning around these array definitions using the kernel's
__diag infrastructure, since the pattern is intentional and widespread
across all CPU-specific perf map variants in this file.

Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
---
drivers/perf/arm_v7_pmu.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/drivers/perf/arm_v7_pmu.c b/drivers/perf/arm_v7_pmu.c
index a1e438101114..9ac28c8adf80 100644
--- a/drivers/perf/arm_v7_pmu.c
+++ b/drivers/perf/arm_v7_pmu.c
@@ -146,6 +146,15 @@

#define SCORPION_ITLB_MISS 0x12021

+/*
+ * The perf_map and cache_map arrays use range initializers to fill all
+ * entries with HW_OP_UNSUPPORTED / CACHE_OP_UNSUPPORTED, then override
+ * specific entries with supported event codes. This is valid C99 but
+ * triggers Clang's -Winitializer-overrides.
+ */
+__diag_push();
+__diag_ignore_all("-Winitializer-overrides", "");
+
/*
* Cortex-A8 HW events mapping
*
@@ -530,6 +539,8 @@ static const unsigned scorpion_perf_cache_map[PERF_COUNT_HW_CACHE_MAX]
[C(BPU)][C(OP_WRITE)][C(RESULT_MISS)] = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED,
};

+__diag_pop();
+
PMU_FORMAT_ATTR(event, "config:0-7");

static struct attribute *armv7_pmu_format_attrs[] = {
--
2.56.0