[PATCH] perf riscv: Add perf_regs_load and enable the dwarf unwind test
Ian Rogers
irogers at google.com
Tue Sep 15 12:09:13 PDT 2026
On Mon, Sep 14, 2026 at 6:54 PM Chen Pei <cp0613 at linux.alibaba.com> wrote:
>
> Both items checked. Neither needs a v2 of this patch.
>
> > Does this file need to explicitly include <stdlib.h>? Since musl libc
> > enforces strict POSIX header inclusions, missing the declaration for
> > malloc could lead to a build failure regression on musl libc systems.
>
> It is not missing. "perf_regs.h" three lines above resolves to
> arch/riscv/include/perf_regs.h, which has #include <stdlib.h> and is
> also where PERF_REGS_MAX comes from, so this file cannot be built
> without it. arm64 relies on the same transitive include. Checked with
> riscv64 gcc 15.3, where an implicit declaration is a hard error:
> including only that header is enough to call malloc() and calloc().
Hi Pei,
Thanks for the patch! Please don't rely on transitive includes as a
change in the other header file will break code here. Since this code
only builds for RISC-V, we're likely to miss the problem if the other
header changes. Other than this,
Reviewed-by: Ian Rogers <irogers at google.com>
Thanks,
Ian
> > Can perf_sample__user_regs() return NULL here?
>
> It can, but that is not introduced here and cannot be fixed from this
> file. arch/x86, arch/arm, arch/arm64 and arch/powerpc all dereference
> it the same way, and tests/dwarf-unwind.c:118 does
> zfree(&sample.user_regs->regs) unconditionally, so an early return here
> would still crash in the caller. A fix has to cover the whole "Test
> dwarf unwind" path, or the contract of perf_sample__user_regs() itself.
> Either is a separate series, which I can send if wanted.
>
> Best regards,
> Pei
More information about the linux-riscv
mailing list