From b36a63375f9ea5f86a8dc392a153cc2020e73551 Mon Sep 17 00:00:00 2001 From: Dapeng Mi Date: Sun, 28 Sep 2025 13:50:47 +0800 Subject: [PATCH] Fixup: perf/x86/intel: Fix NULL event access waring from test robot This patch fixes the warning about https://lore.kernel.org/all/202509081646.d101cfb7-lkp@intel.com/. Signed-off-by: Dapeng Mi --- arch/x86/events/intel/ds.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index 65908880f424..3dedf7a0acf6 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -2781,9 +2781,11 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs, struct perf_sample_d /* PEBS v3 has more accurate status bits */ if (x86_pmu.intel_cap.pebs_format >= 3) { - for_each_set_bit(bit, (unsigned long *)&pebs_status, size) + for_each_set_bit(bit, (unsigned long *)&pebs_status, size) { counts[bit]++; - + if (counts[bit] && !events[bit]) + events[bit] = cpuc->events[bit]; + } continue; } @@ -2821,8 +2823,11 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs, struct perf_sample_d * If collision happened, the record will be dropped. */ if (pebs_status != (1ULL << bit)) { - for_each_set_bit(i, (unsigned long *)&pebs_status, size) + for_each_set_bit(i, (unsigned long *)&pebs_status, size) { error[i]++; + if (error[i] && !events[i]) + events[i] = cpuc->events[i]; + } continue; } -- 2.34.1