Re: [PATCH 22/24] alpha: add HAVE_PERF_REGS and HAVE_PERF_USER_STACK_DUMP support
From: Magnus Lindholm
Date: Thu Sep 03 2026 - 17:09:53 EST
Hi Matt,
On Tue, Sep 1, 2026 at 5:51 PM Matt Turner <mattst88@xxxxxxxxx> wrote:
>
> Implement the perf register sampling interface for Alpha. This enables
> perf to capture register state and user stack dumps with samples,
> supporting --call-graph dwarf.
>
> The perf_regs enum exposes the registers available in pt_regs: r0-r8,
> r16-r28, gp, pc, and ps. Registers r9-r15 are callee-saved and live
> in switch_stack, not pt_regs, so they are not included.
>
> A switch statement maps perf register indices to pt_regs fields since
> Alpha's pt_regs layout is non-contiguous (unlike architectures where
> direct array indexing works).
>
I tested this on an Alpha UP2000. Basic perf recording works, but
user-register and user-stack sampling still appear to need some
additional work.
`perf record --user-regs=?` reports an empty register list, since
tools/perf does not yet provide the Alpha register mask, names, or
IP/SP mappings. Adding DWARF call-graph sampling consequently fails
with EINVAL. I think the corresponding tools/perf support could be
added as a separate patch in this series.
There also appears to be one kernel-side issue with user-stack
sampling. The generic code obtains the stack pointer through
user_stack_pointer(regs), which returns regs->usp on Alpha.
Alpha already has alpha_snapshot_usp(), which initializes this field
for user-mode register frames, but it is currently local to traps.c
and is only called from do_entArith() and do_entIF(). The interrupt
entry path through do_entInt() does not call it.
Perhaps alpha_snapshot_usp() could be moved to a shared header and
called near the beginning of do_entInt(), before dispatching the
interrupt. That would ensure that perf_irq() receives a valid
regs->usp for interrupts taken from userspace, without adding this
work to the SAVE_ALL assembly macro.
The perf register ABI also appears to be missing SP. This could be
provided using current_user_stack_pointer(), as in the older Alpha
implementation.
I have some older Alpha kernel and tools/perf patches which implement
similar support. They target an older API, but I will send them
off-list in case any of the code is useful. Please feel free to reuse
or adapt whatever helps.
Regards,
Magnus