[Patch v7 24/24] perf/x86/intel: Fix incorrect PERF_METRICS overflow bit clearing

From: Dapeng Mi

Date: Tue Nov 17 2026 - 22:25:36 EST


The overflow status bit for PERF_METRICS is cleared incorrectly in
handle_pmi_common(). The code clears the raw bit index value instead of
the corresponding BIT_ULL(...) mask, which leaves the overflow flag in
an incorrect state.

Define GLOBAL_STATUS_PERF_METRICS_OVF as the proper bit mask and use it
when clearing the PERF_METRICS overflow bit in handle_pmi_common().

Fixes: a5f5e1238f4f ("perf/x86/intel: Don't clear perf metrics overflow bit unconditionally")
Fixes: d21954c8a0ff ("perf/x86/intel: Process arch-PEBS records or record fragments")
Signed-off-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>
---
arch/x86/events/intel/core.c | 4 ++--
arch/x86/include/asm/perf_event.h | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
index b4632b791e26..d7284eb73227 100644
--- a/arch/x86/events/intel/core.c
+++ b/arch/x86/events/intel/core.c
@@ -3972,7 +3972,7 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)
*/
if (cpuc->events[INTEL_PMC_IDX_FIXED_SLOTS] &&
is_pebs_counter_event_group(cpuc->events[INTEL_PMC_IDX_FIXED_SLOTS]))
- status &= ~GLOBAL_STATUS_PERF_METRICS_OVF_BIT;
+ status &= ~GLOBAL_STATUS_PERF_METRICS_OVF;
}

/*
@@ -3987,7 +3987,7 @@ static int handle_pmi_common(struct pt_regs *regs, u64 status)

if (cpuc->events[INTEL_PMC_IDX_FIXED_SLOTS] &&
is_pebs_counter_event_group(cpuc->events[INTEL_PMC_IDX_FIXED_SLOTS]))
- status &= ~GLOBAL_STATUS_PERF_METRICS_OVF_BIT;
+ status &= ~GLOBAL_STATUS_PERF_METRICS_OVF;
}

/*
diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
index 5c92d43bbef8..63e1d1bcd01a 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -452,6 +452,7 @@ static inline bool is_topdown_idx(int idx)
#define GLOBAL_STATUS_ARCH_PEBS_THRESHOLD_BIT 54
#define GLOBAL_STATUS_ARCH_PEBS_THRESHOLD BIT_ULL(GLOBAL_STATUS_ARCH_PEBS_THRESHOLD_BIT)
#define GLOBAL_STATUS_PERF_METRICS_OVF_BIT 48
+#define GLOBAL_STATUS_PERF_METRICS_OVF BIT_ULL(GLOBAL_STATUS_PERF_METRICS_OVF_BIT)

#define GLOBAL_CTRL_EN_PERF_METRICS BIT_ULL(48)
/*
--
2.34.1