Re: [PATCH v2] perf: libdw support for powerpc [ping]

From: Ravi Bangoria
Date: Mon Jun 12 2017 - 07:59:00 EST


Hi Paolo,

Thanks for the patch and really sorry for being late. I was quite busy
with few other things.

On Friday 09 June 2017 06:00 PM, Paolo Bonzini wrote:
>
> On 01/06/2017 12:24, Paolo Bonzini wrote:
>> Porting PPC to libdw only needs an architecture-specific hook to move
>> the register state from perf to libdw.
>>
>> The ARM and x86 architectures already use libdw, and it is useful to
>> have as much common code for the unwinder as possible. Mark Wielaard
>> has contributed a frame-based unwinder to libdw, so that unwinding works
>> even for binaries that do not have CFI information. In addition,
>> libunwind is always preferred to libdw by the build machinery so this
>> cannot introduce regressions on machines that have both libunwind and
>> libdw installed.
>>
>> Cc: acme@xxxxxxxxxx
>> Cc: Naveen N. Rao <naveen.n.rao@xxxxxxxxxxxxxxxxxx>
>> Cc: Ravi Bangoria <ravi.bangoria@xxxxxxxxxxxxxxxxxx>
>> Cc: linuxppc-dev@xxxxxxxxxxxxxxxx
>> Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
>> ---
>> v1->v2: fix for 4.11->4.12 changes
> Ravi, Naveen, any reviews?

So, I tested this patch along with Mark's patch[1] on elfutils an looks
like it's not working. Steps on what I did:

After applying Mark's patch on upstream elfutils:

$ aclocal
$ autoheader
$ autoconf
$ automake --add-missing
$ ./configure
$ make
$ make install DESTDIR=/home/ravi/elfutils-git

After applying your patch on upstream perf:

$ make
$ ./perf record --call-graph=dwarf ls
$ LD_LIBRARY_PATH=/home/ravi/elfutils-git/usr/local/lib:\
/home/ravi/elfutils-git/usr/local/lib/elfutils/:$LD_LIBRARY_PATH \
./perf script

ls 44159 1800.878468: 191408 cycles:u:

ls 44159 1800.878673: 419356 cycles:u:
8a97c hpte_need_flush (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
835f4 flush_hash_page (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
8acec hpte_need_flush (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
3468f4 ptep_clear_flush (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
328b10 wp_page_copy (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
32ebe4 do_wp_page (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
33434c __handle_mm_fault (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
335040 handle_mm_fault (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
7bf94 do_page_fault (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
1a4f8 handle_page_fault (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)

ls 44159 1800.878961: 430876 cycles:u:

ls 44159 1800.879195: 423785 cycles:u:

ls 44159 1800.879360: 427359 cycles:u:

Here I don't see userspace callchain getting unwound. Please let me know
if I'm doing anything wrong. Same perf.data with libunwind:

ls 44159 1800.878468: 191408 cycles:u:
20380 _dl_sysdep_start (/usr/lib64/ld-2.17.so)
1c7f _dl_start_final (/usr/lib64/ld-2.17.so)
5ce7 _dl_start (/usr/lib64/ld-2.17.so)
1937 _start (/usr/lib64/ld-2.17.so)

ls 44159 1800.878673: 419356 cycles:u:
8a97c hpte_need_flush (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
835f4 flush_hash_page (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
8acec hpte_need_flush (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
3468f4 ptep_clear_flush (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
328b10 wp_page_copy (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
32ebe4 do_wp_page (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
33434c __handle_mm_fault (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
335040 handle_mm_fault (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
7bf94 do_page_fault (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
1a4f8 handle_page_fault (/usr/lib/debug/lib/modules/4.11.0-3.el7.ppc64le/vmlinux)
7cd4 _dl_map_object_from_fd (/usr/lib64/ld-2.17.so)
b24b _dl_map_object (/usr/lib64/ld-2.17.so)
12b3b openaux (/usr/lib64/ld-2.17.so)
159bf _dl_catch_error (/usr/lib64/ld-2.17.so)
13323 _dl_map_object_deps (/usr/lib64/ld-2.17.so)
3feb dl_main (/usr/lib64/ld-2.17.so)
2045b _dl_sysdep_start (/usr/lib64/ld-2.17.so)
1c7f _dl_start_final (/usr/lib64/ld-2.17.so)
5ce7 _dl_start (/usr/lib64/ld-2.17.so)
1937 _start (/usr/lib64/ld-2.17.so)

ls 44159 1800.878961: 430876 cycles:u:
dcb8 check_match.10245 (/usr/lib64/ld-2.17.so)
e55b do_lookup_x (/usr/lib64/ld-2.17.so)
e8d7 _dl_lookup_symbol_x (/usr/lib64/ld-2.17.so)
10493 _dl_relocate_object (/usr/lib64/ld-2.17.so)
4cf7 dl_main (/usr/lib64/ld-2.17.so)
2045b _dl_sysdep_start (/usr/lib64/ld-2.17.so)
1c7f _dl_start_final (/usr/lib64/ld-2.17.so)
5ce7 _dl_start (/usr/lib64/ld-2.17.so)
1937 _start (/usr/lib64/ld-2.17.so)

ls 44159 1800.879195: 423785 cycles:u:
960a0 malloc (/usr/lib64/libc-2.17.so)
32a53 _nl_intern_locale_data (/usr/lib64/libc-2.17.so)
3337f _nl_load_locale_from_archive (/usr/lib64/libc-2.17.so)
323b3 _nl_find_locale (/usr/lib64/libc-2.17.so)
31b93 setlocale (/usr/lib64/libc-2.17.so)
2a8b _init (/usr/bin/ls)
2497f generic_start_main.isra.0 (/usr/lib64/libc-2.17.so)
24b73 __libc_start_main (/usr/lib64/libc-2.17.so)

ls 44159 1800.879360: 427359 cycles:u:
a42b8 get_next_seq (/usr/lib64/libc-2.17.so)
a54ff __strcoll_l (/usr/lib64/libc-2.17.so)


[1] https://sourceware.org/ml/elfutils-devel/2017-q2/msg00223.html