Add support for perf user stack dump in powerpc
Subsystems (3)
cover Add support for perf user stack dump in powerpc
This patch set enables perf user stack dump on powerpc
Example with "ls" command as user program
./perf record --call-graph=dwarf,8192 ls
./perf script
---------8< -----
..
...
perf 12549 75938.934539: 1771 cycles:ppp:
210d90 .perf_event_exec (/boot/vmlinux)
34b914 .load_elf_binary (/boot/vmlinux)
2dcabc .search_binary_handler (/boot/vmlinux)
2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux)
2ddcd8 .sys_execve (/boot/vmlinux)
19258 system_call (/boot/vmlinux)perf 12549 75938.934549: 8415 cycles:ppp:
207a88 .perf_event_aux_ctx (/boot/vmlinux)
0 [unknown] ([unknown])
214ab8 .perf_event_comm (/boot/vmlinux)
2dcfb8 .__set_task_comm (/boot/vmlinux)
2ddb44 .setup_new_exec (/boot/vmlinux)
34b914 .load_elf_binary (/boot/vmlinux)
2dcabc .search_binary_handler (/boot/vmlinux)
2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux)
2ddcd8 .sys_execve (/boot/vmlinux)
19258 system_call (/boot/vmlinux)ls 12549 75938.934562: 33745 cycles:ppp:
ee570 .task_work_add (/boot/vmlinux)
0 [unknown] ([unknown])
2ce380 .filp_close (/boot/vmlinux)
2fc464 .do_close_on_exec (/boot/vmlinux)
2ddbd8 .setup_new_exec (/boot/vmlinux)
34b914 .load_elf_binary (/boot/vmlinux)
2dcabc .search_binary_handler (/boot/vmlinux)
2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux)
2ddcd8 .sys_execve (/boot/vmlinux)
19258 system_call (/boot/vmlinux)ls 12549 75938.934587: 116078 cycles:ppp:
6ff94 .__clear_user (/boot/vmlinux)
944400 .padzero ([kernel.vmlinux].text.unlikely)
34bd28 .load_elf_binary (/boot/vmlinux)
2dcabc .search_binary_handler (/boot/vmlinux)
2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux)
2ddcd8 .sys_execve (/boot/vmlinux)
19258 system_call (/boot/vmlinux)...
..
----- 8< -----
Chandan Kumar (2):
powerpc: Add HAVE_PERF_USER_STACK_DUMP support powerpc/perf: Add support for unwinding perf-stackdump
Naveen N. Rao (1):
perf tools: Fix perf regs mask generation
.../features/perf/perf-regs/arch-support.txt | 2 +- .../features/perf/perf-stackdump/arch-support.txt | 2 +- arch/powerpc/Kconfig | 1 + tools/perf/arch/powerpc/util/Build | 1 + tools/perf/arch/powerpc/util/unwind-libunwind.c | 96 ++++++++++++++++++++++ tools/perf/config/Makefile | 1 + tools/perf/util/perf_regs.c | 8 +- 7 files changed, 105 insertions(+), 6 deletions(-) create mode 100644 tools/perf/arch/powerpc/util/unwind-libunwind.c
Signature · 1 line
1.9.3
PATCH 3/3 perf tools: Fix perf regs mask generation
From: "Naveen N. Rao" <[email protected]>
On some architectures (powerpc in particular), the number of registers exceeds what can be represented in an integer bitmask. Ensure we generate the proper bitmask on such platforms.
processing")
--- tools/perf/util/perf_regs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/perf/util/perf_regs.c +4 -4
@@ -12,18 +12,18 @@ int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)int i, idx =0 ;u64 mask = regs->mask; -if (regs->cache_mask & (1 << id)) +if (regs->cache_mask & (1ULL << id)) goto out; -if (!(mask & (1 << id))) +if (!(mask & (1ULL << id)))return -EINVAL ;for (i =0 ; i < id; i++) { -if (mask & (1 << i)) +if (mask & (1ULL << i)) idx++; } - regs->cache_mask |= (1 << id); + regs->cache_mask |= (1ULL << id); regs->cache_regs[id] = regs->regs[idx]; out:
Signature · 1 line
1.9.3
PATCH 2/3 powerpc/perf: Add support for unwinding perf-stackdump
In reply to Chandan KumarAdds support for unwinding user stack dump by linking with libunwind.
--- tools/perf/arch/powerpc/util/Build | 1 + tools/perf/arch/powerpc/util/unwind-libunwind.c | 96 +++++++++++++++++++++++++ tools/perf/config/Makefile | 1 + 3 files changed, 98 insertions(+) create mode 100644 tools/perf/arch/powerpc/util/unwind-libunwind.c
tools/perf/arch/powerpc/util/Build +1 -0
@@ -5,3 +5,4 @@ libperf-y += perf_regs.o libperf-$(CONFIG_DWARF) += dwarf-regs.o libperf-$(CONFIG_DWARF) += skip-callchain-idx.o +libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o
tools/perf/arch/powerpc/util/unwind-libunwind.c new file +96 -0
96 lines not on this page · raw message
tools/perf/config/Makefile +1 -0
@@ -26,6 +26,7 @@ NO_PERF_REGS := 1 # Additional ARCH settings for ppc ifeq ($(ARCH),powerpc) NO_PERF_REGS := 0 + LIBUNWIND_LIBS := -lunwind -lunwind-ppc64 endif # Additional ARCH settings for x86
Signature · 1 line
1.9.3
PATCH 1/3 powerpc: Add HAVE_PERF_USER_STACK_DUMP support
In reply to Chandan KumarWith perf regs support enabled for powerpc, the support for obtaining perf user stack dump is already enabled.
This patch declares the support for same and also updates documentation to mark the support for perf-regs and perf-stackdump.
--- Documentation/features/perf/perf-regs/arch-support.txt | 2 +- Documentation/features/perf/perf-stackdump/arch-support.txt | 2 +- arch/powerpc/Kconfig | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
Documentation/features/perf/perf-regs/arch-support.txt +1 -1
@@ -27,7 +27,7 @@ | nios2: | TODO | | openrisc: | TODO | | parisc: | TODO | - | powerpc: | TODO | + | powerpc: | ok | | s390: | TODO | | score: | TODO | | sh: | TODO |
Documentation/features/perf/perf-stackdump/arch-support.txt +1 -1
@@ -27,7 +27,7 @@ | nios2: | TODO | | openrisc: | TODO | | parisc: | TODO | - | powerpc: | TODO | + | powerpc: | ok | | s390: | TODO | | score: | TODO | | sh: | TODO |
arch/powerpc/Kconfig +1 -0
@@ -117,6 +117,7 @@ config PPC select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select HAVE_PERF_EVENTS select HAVE_PERF_REGS + select HAVE_PERF_USER_STACK_DUMP select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64 select ARCH_WANT_IPC_PARSE_VERSION
Signature · 1 line
1.9.3
Quoted 1 line · Chandan Kumar
This patch set enables perf user stack dump on powerpc
For this patch-set:
I suppose that implies my testing, but nonetheless:
Quoted 9 lines
Example with "ls" command as user program
./perf record --call-graph=dwarf,8192 ls./perf script
---------8< -----
..
...
perf 12549 75938.934539: 1771 cycles:ppp:
Quoted 6 lines
210d90 .perf_event_exec (/boot/vmlinux)
34b914 .load_elf_binary (/boot/vmlinux)
2dcabc .search_binary_handler (/boot/vmlinux)
2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux)
2ddcd8 .sys_execve (/boot/vmlinux)
19258 system_call (/boot/vmlinux)To expand on this, with upstream libunwind
(git://git.sv.gnu.org/libunwind.git) and with debuginfo installed:
# ./perf record -e cycles -g --call-graph dwarf -- find . -iname
'*linux*'
./tests/vmlinux-kallsyms.c
./tests/vmlinux-kallsyms.o
./tests/.vmlinux-kallsyms.o.cmd
./util/include/linux
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 0.371 MB perf.data (45 samples) ]
# ./perf script
<snip>
find 23858 167788.657182: 881967 cycles:
8e758c _cond_resched (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
3f83bc selinux_inode_getattr (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
3ee254 security_inode_getattr (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
3063a4 vfs_getattr (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
306530 vfs_fstatat (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
306c60 sys_newfstatat (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
19210 system_call (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux)
3fffa31829a8 __fxstatat64 (/usr/lib64/libc-2.17.so)
10025ac8 fts_stat.isra.2 (/usr/bin/find)
10027c04 fts_read (/usr/bin/find)
10003e18 find (/usr/bin/find)
100035ec main (/usr/bin/find)
3fffa30a4580 generic_start_main.isra.0 (/usr/lib64/libc-2.17.so)
3fffa30a4774 __libc_start_main (/usr/lib64/libc-2.17.so)<snip>
Arnaldo, Michael,
Can we take this through powerpc/next as well since this pretty much rides on the recent perf regs work?
- Naveen
Arnaldo Carvalho de Melo
Acked-byEm Thu, Apr 28, 2016 at 07:53:41PM +0530, Naveen N. Rao escreveu:
Quoted 54 lines · Chandan Kumar
Quoted 1 line
This patch set enables perf user stack dump on powerpc
For this patch-set:
Reviewed-by Naveen N. Rao <[email protected]>I suppose that implies my testing, but nonetheless:
Tested-by Naveen N. Rao <[email protected]>Quoted 9 lines
Example with "ls" command as user program
./perf record --call-graph=dwarf,8192 ls./perf script
---------8< -----
..
...
perf 12549 75938.934539: 1771 cycles:ppp:Quoted 6 lines
210d90 .perf_event_exec (/boot/vmlinux) 34b914 .load_elf_binary (/boot/vmlinux) 2dcabc .search_binary_handler (/boot/vmlinux) 2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux) 2ddcd8 .sys_execve (/boot/vmlinux) 19258 system_call (/boot/vmlinux)To expand on this, with upstream libunwind
(git://git.sv.gnu.org/libunwind.git) and with debuginfo installed:# ./perf record -e cycles -g --call-graph dwarf -- find . -iname '*linux*' ./tests/vmlinux-kallsyms.c ./tests/vmlinux-kallsyms.o ./tests/.vmlinux-kallsyms.o.cmd ./util/include/linux [ perf record: Woken up 2 times to write data ] [ perf record: Captured and wrote 0.371 MB perf.data (45 samples) ] # ./perf script <snip> find 23858 167788.657182: 881967 cycles: 8e758c _cond_resched (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 3f83bc selinux_inode_getattr (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 3ee254 security_inode_getattr (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 3063a4 vfs_getattr (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 306530 vfs_fstatat (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 306c60 sys_newfstatat (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 19210 system_call (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 3fffa31829a8 __fxstatat64 (/usr/lib64/libc-2.17.so) 10025ac8 fts_stat.isra.2 (/usr/bin/find) 10027c04 fts_read (/usr/bin/find) 10003e18 find (/usr/bin/find) 100035ec main (/usr/bin/find) 3fffa30a4580 generic_start_main.isra.0 (/usr/lib64/libc-2.17.so) 3fffa30a4774 __libc_start_main (/usr/lib64/libc-2.17.so)
Quoted 6 lines
<snip>
Arnaldo, Michael,
Can we take this through powerpc/next as well since this pretty much rides on the recent perf regs work?
I haven't tested with the bits that touch the common code, have you? But I think it should be harmless and overall this patchset looks fine, so, if you, just in case, have tested this on a x86_64 machine and all seems well, i.e. perf test, perf record/report with a perf-probe generated event, to exercise this stuff, then:
Quoted 62 lines · Arnaldo Carvalho de Melo
Em Thu, Apr 28, 2016 at 07:53:41PM +0530, Naveen N. Rao escreveu:
Quoted 54 lines · Chandan Kumar
Quoted 1 line
This patch set enables perf user stack dump on powerpc
For this patch-set:
Reviewed-by Naveen N. Rao <[email protected]>I suppose that implies my testing, but nonetheless:
Tested-by Naveen N. Rao <[email protected]>Quoted 9 lines
Example with "ls" command as user program
./perf record --call-graph=dwarf,8192 ls./perf script
---------8< -----
..
...
perf 12549 75938.934539: 1771 cycles:ppp:Quoted 6 lines
210d90 .perf_event_exec (/boot/vmlinux) 34b914 .load_elf_binary (/boot/vmlinux) 2dcabc .search_binary_handler (/boot/vmlinux) 2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux) 2ddcd8 .sys_execve (/boot/vmlinux) 19258 system_call (/boot/vmlinux)To expand on this, with upstream libunwind
(git://git.sv.gnu.org/libunwind.git) and with debuginfo installed:# ./perf record -e cycles -g --call-graph dwarf -- find . -iname '*linux*' ./tests/vmlinux-kallsyms.c ./tests/vmlinux-kallsyms.o ./tests/.vmlinux-kallsyms.o.cmd ./util/include/linux [ perf record: Woken up 2 times to write data ] [ perf record: Captured and wrote 0.371 MB perf.data (45 samples) ] # ./perf script <snip> find 23858 167788.657182: 881967 cycles: 8e758c _cond_resched (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 3f83bc selinux_inode_getattr (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 3ee254 security_inode_getattr (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 3063a4 vfs_getattr (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 306530 vfs_fstatat (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 306c60 sys_newfstatat (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 19210 system_call (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 3fffa31829a8 __fxstatat64 (/usr/lib64/libc-2.17.so) 10025ac8 fts_stat.isra.2 (/usr/bin/find) 10027c04 fts_read (/usr/bin/find) 10003e18 find (/usr/bin/find) 100035ec main (/usr/bin/find) 3fffa30a4580 generic_start_main.isra.0 (/usr/lib64/libc-2.17.so) 3fffa30a4774 __libc_start_main (/usr/lib64/libc-2.17.so)Quoted 6 lines
<snip>
Arnaldo, Michael,
Can we take this through powerpc/next as well since this pretty much rides on the recent perf regs work?
Quoted 5 lines
I haven't tested with the bits that touch the common code, have you? But I think it should be harmless and overall this patchset looks fine, so, if you, just in case, have tested this on a
x86_64machine and all seems well, i.e. perf test, perf record/report with a perf-probe generated event, to exercise this stuff, then:
Yes, I processed a perf.data file that had the user stackdump unwound with libunwind with/without patch 3 and the output matches. And:
# ./perf test 46 46: Test dwarf unwind : Ok
Quoted 3 lines
Thanks.
- Naveen
Arnaldo Carvalho de Melo
Acked-byEm Thu, Apr 28, 2016 at 09:44:29PM +0530, Naveen N. Rao escreveu:
Quoted 69 lines · Arnaldo Carvalho de Melo
Quoted 62 lines
Em Thu, Apr 28, 2016 at 07:53:41PM +0530, Naveen N. Rao escreveu:
Quoted 54 lines · Chandan Kumar
Quoted 1 line
This patch set enables perf user stack dump on powerpc
For this patch-set:
Reviewed-by Naveen N. Rao <[email protected]>I suppose that implies my testing, but nonetheless:
Tested-by Naveen N. Rao <[email protected]>Quoted 9 lines
Example with "ls" command as user program
./perf record --call-graph=dwarf,8192 ls./perf script
---------8< -----
..
...
perf 12549 75938.934539: 1771 cycles:ppp:Quoted 6 lines
210d90 .perf_event_exec (/boot/vmlinux) 34b914 .load_elf_binary (/boot/vmlinux) 2dcabc .search_binary_handler (/boot/vmlinux) 2dd6f0 .do_execveat_common.isra.28 (/boot/vmlinux) 2ddcd8 .sys_execve (/boot/vmlinux) 19258 system_call (/boot/vmlinux)To expand on this, with upstream libunwind
(git://git.sv.gnu.org/libunwind.git) and with debuginfo installed:# ./perf record -e cycles -g --call-graph dwarf -- find . -iname '*linux*' ./tests/vmlinux-kallsyms.c ./tests/vmlinux-kallsyms.o ./tests/.vmlinux-kallsyms.o.cmd ./util/include/linux [ perf record: Woken up 2 times to write data ] [ perf record: Captured and wrote 0.371 MB perf.data (45 samples) ] # ./perf script <snip> find 23858 167788.657182: 881967 cycles: 8e758c _cond_resched (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 3f83bc selinux_inode_getattr (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 3ee254 security_inode_getattr (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 3063a4 vfs_getattr (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 306530 vfs_fstatat (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 306c60 sys_newfstatat (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 19210 system_call (/lib/modules/4.6.0-rc3-nnr+/build/vmlinux) 3fffa31829a8 __fxstatat64 (/usr/lib64/libc-2.17.so) 10025ac8 fts_stat.isra.2 (/usr/bin/find) 10027c04 fts_read (/usr/bin/find) 10003e18 find (/usr/bin/find) 100035ec main (/usr/bin/find) 3fffa30a4580 generic_start_main.isra.0 (/usr/lib64/libc-2.17.so) 3fffa30a4774 __libc_start_main (/usr/lib64/libc-2.17.so)Quoted 6 lines
<snip>
Arnaldo, Michael,
Can we take this through powerpc/next as well since this pretty much rides on the recent perf regs work?Quoted 5 lines
I haven't tested with the bits that touch the common code, have you? But I think it should be harmless and overall this patchset looks fine, so, if you, just in case, have tested this on a
x86_64machine and all seems well, i.e. perf test, perf record/report with a perf-probe generated event, to exercise this stuff, then:
Quoted 5 lines
Yes, I processed a perf.data file that had the user stackdump unwound with libunwind with/without patch 3 and the output matches. And:
# ./perf test 46 46: Test dwarf unwind : Ok
Ok then,
Re: [1/3] powerpc: Add HAVE_PERF_USER_STACK_DUMP support
In reply to Chandan KumarQuoted 6 lines · Chandan Kumar
With perf regs support enabled for powerpc, the support for obtaining perf user stack dump is already enabled.
This patch declares the support for same and also updates documentation to mark the support for perf-regs and perf-stackdump.Signed-off-by Chandan Kumar <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/08c1f9ec28d2d156aca29f7752
cheers
Re: [2/3] powerpc/perf: Add support for unwinding perf-stackdump
In reply to Chandan KumarQuoted 3 lines · Chandan Kumar
Adds support for unwinding user stack dump by linking with libunwind.
Signed-off-by Chandan Kumar <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/7b87053070496576725b2be81b
cheers
Re: [3/3] perf tools: Fix perf regs mask generation
In reply to Chandan KumarQuoted 10 lines · Chandan Kumar
From: "Naveen N. Rao" <[email protected]>
On some architectures (powerpc in particular), the number of registers exceeds what can be represented in an integer bitmask. Ensure we generate the proper bitmask on such platforms.
Fixes 71ad0f5e4 ("perf tools: Support for DWARF CFI unwinding on postprocessing")
Signed-off-by Naveen N. Rao <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/826dccfd238c3eeac379f5f637
cheers