Skip to content

Add the ability to choose in-kernel frame pointer unwinding of the user stack #3300

@mstange

Description

@mstange

The ability to use frame pointer unwinding landed in ab3bf51. But as far as I can tell this still copies the user stack bytes and does the unwinding in user-land, which is slow (copies a lot of memory) and which leads to truncated stacks because it can only unwind the top 64KB of the stack.

if (IsUserFramesEnabled(unwind_mode)) {
pe.sample_type |= PERF_SAMPLE_STACK_USER | PERF_SAMPLE_REGS_USER;
// PERF_SAMPLE_STACK_USER:
// Needs to be < ((u16)(~0u)), and have bottom 8 bits clear.
// Note that the kernel still needs to make space for the other parts of the
// sample (up to the max record size of 64k), so the effective maximum
// can be lower than this.
pe.sample_stack_user = (1u << 16) - 256;
// PERF_SAMPLE_REGS_USER:
pe.sample_regs_user =
PerfUserRegsMaskForArch(unwindstack::Regs::CurrentArch());
}
if (kernel_frames) {
pe.sample_type |= PERF_SAMPLE_CALLCHAIN;
pe.exclude_callchain_user = true;
}

I would like to have a path which asks the kernel to do the unwinding of the user stack, i.e. which uses PERF_SAMPLE_CALLCHAIN, and which does not drop the user frames (exclude_callchain_user = false). This path would not set PERF_SAMPLE_STACK_USER, i.e. it would skip the copying of the stack bytes.

Could such a path be added? cc @LalitMaganti

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions