All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 00/15] perf: Add backtrace post dwarf unwind
@ 2012-03-28 12:35 Jiri Olsa
  2012-03-28 12:35 ` [PATCH 01/15] perf, tool: Fix the array pointer to follow event data properly Jiri Olsa
                   ` (15 more replies)
  0 siblings, 16 replies; 36+ messages in thread
From: Jiri Olsa @ 2012-03-28 12:35 UTC (permalink / raw)
  To: acme, a.p.zijlstra, mingo, paulus, cjashfor, fweisbec
  Cc: eranian, gorcunov, tzanussi, mhiramat, rostedt, robert.richter,
	fche, linux-kernel

hi,
sending RFC version of the post unwinding user stack backtrace
using dwarf unwind - via libunwind. The original work was
done by Frederic. I mostly took his patches and make them
compile in current kernel code plus I added some stuff here
and there.

The main idea is to store user registers and portion of user
stack when the sample data during the record phase. Then during
the report, when the data is presented, perform the actual dwarf
dwarf unwind.

attached patches:
 01/15 perf, tool: Fix the array pointer to follow event data properly
 02/15 uaccess: Add new copy_from_user_gup API
 03/15 perf: Unified API to record selective sets of arch registers
 04/15 perf: Add ability to dump user regs
 05/15 perf: Add ability to dump part of the user stack
 06/15 perf: Add attribute to filter out user callchains
 07/15 perf, tool: Factor DSO symtab types to generic binary types
 08/15 perf, tool: Add interface to read DSO image data
 09/15 perf, tool: Add '.note' check into search for NOTE section
 10/15 perf, tool: Back [vdso] DSO with real data
 11/15 perf, tool: Add interface to arch registers sets
 12/15 perf, tool: Add libunwind dependency for dwarf cfi unwinding
 13/15 perf, tool: Support user regs and stack in sample parsing
 14/15 perf, tool: Support for dwarf cfi unwinding on post processing
 15/15 perf, tool: Support for dwarf mode callchain on perf record

The unwind processing could considerably prolong the computing
time of the report command, but I believe this could be improved.
   - caching DSO data accesses (as suggested in patch 8/15)
   - maybe separate thread with unwind processing on background,
     so the user does no need to wait for all the data to be
     processed.

I tested on Fedora. There was not much gain on i386, because the
binaries are compiled with frame pointers. Thought the dwarf
backtrace is more accurade and unwraps calls in more details
(functions that do not set the frame pointers).

I could see some improvement on x86_64, where I got full backtrace
where current code could got just the first address out of the
instruction pointer.

Example on x86_64:
[dwarf]
   perf record -g -e syscalls:sys_enter_write date

   100.00%     date  libc-2.14.90.so  [.] __GI___libc_write
               |
               --- __GI___libc_write
                   _IO_file_write@@GLIBC_2.2.5
                   new_do_write
                   _IO_do_write@@GLIBC_2.2.5
                   _IO_file_overflow@@GLIBC_2.2.5
                   0x4022cd
                   0x401ee6
                   __libc_start_main
                   0x4020b9


[frame pointer]
   perf record -g fp -e syscalls:sys_enter_write date

   100.00%     date  libc-2.14.90.so  [.] __GI___libc_write
               |
               --- __GI___libc_write

Also I tested on coreutils binaries mainly, but I could see
getting wider backtraces with dwarf unwind for more complex
application like firefox.

The unwind should go throught [vdso] object. I haven't studied
the [vsyscall] yet, so not sure there.

Attached patches should work on both x86 and x86_64. I did
some initial testing so far.

The unwind backtrace can be interrupted by following reasons:
    - bug in unwind information of processed shared library
    - bug in unwind processing code (most likely ;) )
    - insufficient dump stack size
    - wrong register value - x86_64 does not store whole
      set of registers when in exception, but so far
      it looks like RIP and RSP should be enough

I'd like to have some automated tests on this, but so far nothing
smart is comming to me.. ;)

thanks for comments,
jirka
---
 arch/Kconfig                                       |    7 +
 arch/x86/Kconfig                                   |    1 +
 arch/x86/include/asm/perf_regs.h                   |   15 +
 arch/x86/include/asm/perf_regs_32.h                |   86 +++
 arch/x86/include/asm/perf_regs_64.h                |  101 ++++
 arch/x86/include/asm/uaccess.h                     |    8 +-
 arch/x86/kernel/cpu/perf_event.c                   |    4 +-
 arch/x86/kernel/cpu/perf_event_intel_ds.c          |    3 +-
 arch/x86/kernel/cpu/perf_event_intel_lbr.c         |    2 +-
 arch/x86/lib/usercopy.c                            |    4 +-
 arch/x86/oprofile/backtrace.c                      |    4 +-
 include/asm-generic/uaccess.h                      |    4 +
 include/linux/perf_event.h                         |   36 ++-
 kernel/events/callchain.c                          |    4 +-
 kernel/events/core.c                               |  127 +++++-
 kernel/events/internal.h                           |   59 ++-
 kernel/events/ring_buffer.c                        |    4 +-
 tools/perf/Makefile                                |   40 ++-
 tools/perf/arch/x86/Makefile                       |    3 +
 tools/perf/arch/x86/include/perf_regs.h            |  101 ++++
 tools/perf/arch/x86/util/unwind.c                  |  111 ++++
 tools/perf/builtin-record.c                        |   89 +++-
 tools/perf/builtin-report.c                        |   24 +-
 tools/perf/builtin-script.c                        |   56 ++-
 tools/perf/builtin-test.c                          |    3 +-
 tools/perf/builtin-top.c                           |    7 +-
 tools/perf/config/feature-tests.mak                |   25 +
 tools/perf/perf.h                                  |    9 +-
 tools/perf/util/annotate.c                         |    2 +-
 tools/perf/util/event.h                            |   15 +-
 tools/perf/util/evlist.c                           |   16 +
 tools/perf/util/evlist.h                           |    2 +
 tools/perf/util/evsel.c                            |   36 ++-
 tools/perf/util/include/linux/compiler.h           |    1 +
 tools/perf/util/map.c                              |   16 +-
 tools/perf/util/map.h                              |    7 +-
 tools/perf/util/perf_regs.h                        |   10 +
 tools/perf/util/python.c                           |    3 +-
 .../perf/util/scripting-engines/trace-event-perl.c |    3 +-
 .../util/scripting-engines/trace-event-python.c    |    3 +-
 tools/perf/util/session.c                          |  100 +++-
 tools/perf/util/session.h                          |   10 +-
 tools/perf/util/symbol.c                           |  317 +++++++++---
 tools/perf/util/symbol.h                           |   40 +-
 tools/perf/util/trace-event-scripting.c            |    3 +-
 tools/perf/util/trace-event.h                      |    5 +-
 tools/perf/util/unwind.c                           |  563 ++++++++++++++++++++
 tools/perf/util/unwind.h                           |   34 ++
 tools/perf/util/vdso.c                             |   92 ++++
 tools/perf/util/vdso.h                             |    7 +
 50 files changed, 2023 insertions(+), 199 deletions(-)

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2012-03-30 17:54 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-28 12:35 [RFC 00/15] perf: Add backtrace post dwarf unwind Jiri Olsa
2012-03-28 12:35 ` [PATCH 01/15] perf, tool: Fix the array pointer to follow event data properly Jiri Olsa
2012-03-28 12:35 ` [PATCH 02/15] uaccess: Add new copy_from_user_gup API Jiri Olsa
2012-03-28 12:35 ` [PATCH 03/15] perf: Unified API to record selective sets of arch registers Jiri Olsa
2012-03-30 12:51   ` Cyrill Gorcunov
2012-03-30 13:01     ` Jiri Olsa
2012-03-28 12:35 ` [PATCH 04/15] perf: Add ability to dump user regs Jiri Olsa
2012-03-28 14:01   ` Frank Ch. Eigler
2012-03-28 14:20     ` Jiri Olsa
2012-03-28 15:12       ` Frank Ch. Eigler
2012-03-28 16:01         ` Jiri Olsa
2012-03-28 16:10           ` Frederic Weisbecker
2012-03-28 16:06         ` Frederic Weisbecker
2012-03-28 17:02           ` Jiri Olsa
2012-03-28 21:41             ` Frederic Weisbecker
2012-03-30 14:42   ` Frederic Weisbecker
2012-03-28 12:35 ` [PATCH 05/15] perf: Add ability to dump part of the user stack Jiri Olsa
2012-03-28 12:35 ` [PATCH 06/15] perf: Add attribute to filter out user callchains Jiri Olsa
2012-03-28 12:35 ` [PATCH 07/15] perf, tool: Factor DSO symtab types to generic binary types Jiri Olsa
2012-03-28 12:35 ` [PATCH 08/15] perf, tool: Add interface to read DSO image data Jiri Olsa
2012-03-28 12:35 ` [PATCH 09/15] perf, tool: Add '.note' check into search for NOTE section Jiri Olsa
2012-03-28 12:35 ` [PATCH 10/15] perf, tool: Back [vdso] DSO with real data Jiri Olsa
2012-03-28 12:35 ` [PATCH 11/15] perf, tool: Add interface to arch registers sets Jiri Olsa
2012-03-28 12:35 ` [PATCH 12/15] perf, tool: Add libunwind dependency for dwarf cfi unwinding Jiri Olsa
2012-03-28 12:35 ` [PATCH 13/15] perf, tool: Support user regs and stack in sample parsing Jiri Olsa
2012-03-28 12:35 ` [PATCH 14/15] perf, tool: Support for dwarf cfi unwinding on post processing Jiri Olsa
2012-03-28 12:35 ` [PATCH 15/15] perf, tool: Support for dwarf mode callchain on perf record Jiri Olsa
2012-03-29 17:04 ` [RFC 00/15] perf: Add backtrace post dwarf unwind Stephane Eranian
2012-03-29 23:59   ` Peter Zijlstra
2012-03-30  0:38     ` Stephane Eranian
2012-03-30  0:44       ` Peter Zijlstra
2012-03-30  0:52         ` Stephane Eranian
2012-03-30  7:25           ` Robert Richter
2012-03-30 12:10           ` Masami Hiramatsu
2012-03-30 13:46             ` Ulrich Drepper
2012-03-30 17:54             ` Stephane Eranian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.