LoongArch: Fix callchain parse error with kernel tracepoint events again
authorHuacai Chen <chenhuacai@loongson.cn>
Tue, 14 May 2024 04:24:18 +0000 (12:24 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Tue, 14 May 2024 04:24:18 +0000 (12:24 +0800)
commitd6af2c76399f98444a5b4de96baf4b362d9f102b
treebcf24b1d1a36c8fac2e1ce4e31937738f6448d0f
parent5685d7fcb55fd729d7e0452c157a0ac8d72ca7b6
LoongArch: Fix callchain parse error with kernel tracepoint events again

With commit d3119bc985fb645 ("LoongArch: Fix callchain parse error with
kernel tracepoint events"), perf can parse kernel callchain, but not
complete and sometimes maybe error. The reason is LoongArch's unwinders
(guess, prologue and orc) don't really need fp (i.e., regs[22]), and
they use sp (i.e., regs[3]) as the frame address rather than the current
stack pointer.

Fix that by removing the assignment of regs[22], and instead assign the
__builtin_frame_address(0) to regs[3].

Without fix:

  Children      Self  Command        Shared Object      Symbol
  ........  ........  .............  .................  ................
  33.91%    33.91%    swapper        [kernel.vmlinux]   [k] __schedule
            |
            |--33.04%--__schedule
            |
             --0.87%--__arch_cpu_idle
                       __schedule

With this fix:

  Children      Self  Command        Shared Object      Symbol
  ........  ........  .............  .................  ................
  31.16%    31.16%    swapper        [kernel.vmlinux]   [k] __schedule
            |
            |--20.63%--smpboot_entry
            |          cpu_startup_entry
            |          schedule_idle
            |          __schedule
            |
             --10.53%--start_kernel
                       cpu_startup_entry
                       schedule_idle
                       __schedule

Fixes: d3119bc985fb645 ("LoongArch: Fix callchain parse error with kernel tracepoint events")
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/include/asm/perf_event.h