Re: [Patch v6 05/22] perf/x86: Use x86_perf_regs in the x86 nmi handler
From: Peter Zijlstra
Date: Tue Feb 10 2026 - 13:40:38 EST
On Mon, Feb 09, 2026 at 03:20:30PM +0800, Dapeng Mi wrote:
> 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 a X86 specific x86_perf_regs instead.
>
> 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>
> Signed-off-by: Dapeng Mi <dapeng1.mi@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 6df73e8398cd..8c80d22864d8 100644
> --- a/arch/x86/events/core.c
> +++ b/arch/x86/events/core.c
> @@ -1785,6 +1785,7 @@ EXPORT_SYMBOL_FOR_KVM(perf_put_guest_lvtpc);
> static int
> perf_event_nmi_handler(unsigned int cmd, struct pt_regs *regs)
> {
> + struct x86_perf_regs x86_regs;
> u64 start_clock;
So a few patches ago you pulled this off stack because too large, and
then here you stick it on stack again.
That is a wee bit inconsistent.
Furthermore, I think you can re-purpose that same off-stack copy. After
all, the pebs_drain thing can only happen:
- from NMI (like here);
- from context switch, when PMU is disabled (and thus no NMIs).