Re: [PATCH v2 00/11] unwind, perf: sframe user space unwinding, deferred perf callchains

From: Steven Rostedt
Date: Wed Oct 23 2024 - 22:23:17 EST


On Wed, 23 Oct 2024 15:22:35 +0200
Jens Remus <jremus@xxxxxxxxxxxxx> wrote:

> We are looking forward to implement support for unwinding of user space
> using SFrame in kernel/perf on s390. One major concern is that your x86
> implementation currently relies on a fallback to unwinding using frame
> pointer. On s390 unwinding using frame pointer is unsupported, because
> of lack of proper s390x ABI [1] specification and compiler support. In
> theory there would be a s390-specific alternative of unwinding using
> backchain (compiler option -mbackchain), but this has limitations and
> there is currently no distribution where user space is built with
> backchain.
>
> How much of an issue would it be if s390 could not provide an unwinding
> fallback implementation? Do you see the possibility to get away without?

Yes. Even with x86, there's no guarantee that the applications will
have frame pointers available. Basically it just returns a stack frame
of one (the IP of where user space entered the kernel).

>
> For s390 support of unwinding using SFrame we would need to make a few
> changes to your generic unwinding framework in the kernel:
>
> - Support for architectures that do not define CFA == SP at callsite:
> On s390 the CFA is defined as SP at callsite +160. The stack pointer
> (SP) therefore unwinds as SP = CFA - 160. For that we would introduce
> e.g. a sp_val_off field (SP value offset from CFA) in struct
> user_unwind_frame that would default to 0 on all architectures except
> s390.
>
> - Support for architectures where RA is not necessarily saved on stack:
> On s390 the return address (RA) is not saved (on stack) at function
> entry. In leaf functions it is not necessarily saved at all.
>
> - Support for architectures were RA/FP are saved in registers in leaf
> functions:
> On s390 the frame pointer (FP) and return address (RA) registers can
> be saved in other registers when in leaf functions. In the SFrame
> format we would encode the DWARF register number as offset using the
> least-significant bit as indication: offset = (regnum << 1) | 1.
> Therefore we would need to extend your generic unwinding framework to
> support FP and RA to be restored from registers.
>
> [1]: s390x ELF ABI supplement,
> https://github.com/IBM/s390x-abi/releases

Note that Indu (who's on the Cc and is also the author of sframes) gave
a talk at GNU Cauldron about s390 support. I'm assuming that her new
sframe specification will cover all of this. Then we will have to
implement it.

-- Steve