[PATCH 0/3] perf tools: Random fixes for DWARF unwind

Namhyung Kim posted 3 patches 2 years ago
tools/perf/util/genelf.c                 |  6 +++---
tools/perf/util/unwind-libdw.c           | 21 +++++++++++++++++----
tools/perf/util/unwind-libunwind-local.c |  2 +-
3 files changed, 21 insertions(+), 8 deletions(-)
[PATCH 0/3] perf tools: Random fixes for DWARF unwind
Posted by Namhyung Kim 2 years ago
Hello,

I've found a couple of issues on the unwind code while I'm playing with
the JIT-dump code for the CPython.  The code assumes normal DSOs mapped
from the beginning of the file and aligned to the page size.  But it's
not true for the JIT-dumped DSOs which are generated for each function.

Depending on the JIT implementation, the code address and accompanied
ELF info (like ELF file headers and unwind info) can be overlapped to
adjacent (JIT-dumped) DSOs.  So it should take more care when it
calculates the mapping address for the DSO.

It seems these changes need to go to the stable trees but they are
changed a lot since then so I'm not sure.

Thanks,
Namhyung


Namhyung Kim (3):
  perf genelf: Set ELF program header addresses properly
  perf unwind-libdw: Handle JIT-generated DSOs properly
  perf unwind-libunwind: Fix base address for .eh_frame

 tools/perf/util/genelf.c                 |  6 +++---
 tools/perf/util/unwind-libdw.c           | 21 +++++++++++++++++----
 tools/perf/util/unwind-libunwind-local.c |  2 +-
 3 files changed, 21 insertions(+), 8 deletions(-)

-- 
2.43.0.472.g3155946c3a-goog
Re: [PATCH 0/3] perf tools: Random fixes for DWARF unwind
Posted by Arnaldo Carvalho de Melo 2 years ago
Em Mon, Dec 11, 2023 at 11:05:43PM -0800, Namhyung Kim escreveu:
> Hello,
> 
> I've found a couple of issues on the unwind code while I'm playing with
> the JIT-dump code for the CPython.  The code assumes normal DSOs mapped
> from the beginning of the file and aligned to the page size.  But it's
> not true for the JIT-dumped DSOs which are generated for each function.
> 
> Depending on the JIT implementation, the code address and accompanied
> ELF info (like ELF file headers and unwind info) can be overlapped to
> adjacent (JIT-dumped) DSOs.  So it should take more care when it
> calculates the mapping address for the DSO.
> 
> It seems these changes need to go to the stable trees but they are
> changed a lot since then so I'm not sure.
> 

Thanks, applied to perf-tools-next.

- Arnaldo

 
> 
> Namhyung Kim (3):
>   perf genelf: Set ELF program header addresses properly
>   perf unwind-libdw: Handle JIT-generated DSOs properly
>   perf unwind-libunwind: Fix base address for .eh_frame
> 
>  tools/perf/util/genelf.c                 |  6 +++---
>  tools/perf/util/unwind-libdw.c           | 21 +++++++++++++++++----
>  tools/perf/util/unwind-libunwind-local.c |  2 +-
>  3 files changed, 21 insertions(+), 8 deletions(-)
> 
> -- 
> 2.43.0.472.g3155946c3a-goog
> 

-- 

- Arnaldo
Re: [PATCH 0/3] perf tools: Random fixes for DWARF unwind
Posted by Ian Rogers 2 years ago
On Mon, Dec 11, 2023 at 11:05 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hello,
>
> I've found a couple of issues on the unwind code while I'm playing with
> the JIT-dump code for the CPython.  The code assumes normal DSOs mapped
> from the beginning of the file and aligned to the page size.  But it's
> not true for the JIT-dumped DSOs which are generated for each function.

We have a JIT test in:
https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/tests/shell/test_java_symbol.sh?h=perf-tools-next

It'd be great if we could do similar for CPython.

Thanks,
Ian



> Depending on the JIT implementation, the code address and accompanied
> ELF info (like ELF file headers and unwind info) can be overlapped to
> adjacent (JIT-dumped) DSOs.  So it should take more care when it
> calculates the mapping address for the DSO.
>
> It seems these changes need to go to the stable trees but they are
> changed a lot since then so I'm not sure.
>
> Thanks,
> Namhyung
>
>
> Namhyung Kim (3):
>   perf genelf: Set ELF program header addresses properly
>   perf unwind-libdw: Handle JIT-generated DSOs properly
>   perf unwind-libunwind: Fix base address for .eh_frame
>
>  tools/perf/util/genelf.c                 |  6 +++---
>  tools/perf/util/unwind-libdw.c           | 21 +++++++++++++++++----
>  tools/perf/util/unwind-libunwind-local.c |  2 +-
>  3 files changed, 21 insertions(+), 8 deletions(-)
>
> --
> 2.43.0.472.g3155946c3a-goog
>
Re: [PATCH 0/3] perf tools: Random fixes for DWARF unwind
Posted by Pablo Galindo Salgado 2 years ago
> It'd be great if we could do similar for CPython.

We (the CPython team) plan to release the perf jitdump support for
Python 3.13 (around next October) so you will need to build from
source or wait until is officially released for that test.

Pablo
Re: [PATCH 0/3] perf tools: Random fixes for DWARF unwind
Posted by Namhyung Kim 2 years ago
On Tue, Dec 12, 2023 at 4:54 PM Pablo Galindo Salgado
<pablogsal@gmail.com> wrote:
>
> > It'd be great if we could do similar for CPython.
>
> We (the CPython team) plan to release the perf jitdump support for
> Python 3.13 (around next October) so you will need to build from
> source or wait until is officially released for that test.

Okay, I hope we can have all the fixes asap and most distros ship
the latest version by then.

Thanks,
Namhyung