[RFC PATCH 01/12] perf/x86: Use x86_perf_regs in the x86 nmi handler
From: kan . liang
Date: Fri Jun 13 2025 - 09:59:23 EST
From: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
More and more regs will be supported in the overflow, e.g., more vector
registers, SSP, etc. The generic pt_regs struct cannot store all of
them. Use the X86 specific x86_perf_regs instead. The x86_perf_regs is
already used in PEBS to store the XMM registers.
The struct pt_regs *regs is still passed to x86_pmu_handle_irq(). There
is no functional change for the existing code.
AMD IBS's NMI handler doesn't utilize the static call
x86_pmu_handle_irq(). The x86_perf_regs struct doesn't apply to the AMD
IBS. It can be added separately later when AMD IBS supports more regs.
Signed-off-by: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
---
arch/x86/events/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 7610f26dfbd9..64a7a8aa2e38 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -1752,6 +1752,7 @@ void perf_events_lapic_init(void)
static int
perf_event_nmi_handler(unsigned int cmd, struct pt_regs *regs)
{
+ struct x86_perf_regs x86_regs;
u64 start_clock;
u64 finish_clock;
int ret;
@@ -1764,7 +1765,8 @@ perf_event_nmi_handler(unsigned int cmd, struct pt_regs *regs)
return NMI_DONE;
start_clock = sched_clock();
- ret = static_call(x86_pmu_handle_irq)(regs);
+ x86_regs.regs = *regs;
+ ret = static_call(x86_pmu_handle_irq)(&x86_regs.regs);
finish_clock = sched_clock();
perf_sample_event_took(finish_clock - start_clock);
--
2.38.1