All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv7 00/17] perf: Add backtrace post dwarf unwind
@ 2012-07-22 12:14 Jiri Olsa
  2012-07-22 12:14 ` [PATCH 01/17] perf: Unified API to record selective sets of arch registers Jiri Olsa
                   ` (17 more replies)
  0 siblings, 18 replies; 46+ messages in thread
From: Jiri Olsa @ 2012-07-22 12:14 UTC (permalink / raw)
  To: acme, a.p.zijlstra, mingo, paulus, cjashfor, fweisbec
  Cc: eranian, gorcunov, tzanussi, mhiramat, robert.richter, fche,
	linux-kernel, masami.hiramatsu.pt, drepper, asharma,
	benjamin.redelings

hi,

patches available also as tarball in here:
http://people.redhat.com/~jolsa/perf_post_unwind_v7.tar.bz2

v7 changes:
   - omitted v6 patches 9 and 15
     They need more work and will be sent separately. I dont want to hold off whole
     patchset because of them. We could miss some related backtraces (syscall, vdso)
     in this version.
   - v6 patch 11, 14, 20 already in

v6 changes:
   patch 01/23 - unrelated - ftrace stuff
   patch 03/23 - added PERF_SAMPLE_REGS_USER bit
               - added regs_user initialization
   patch 07/23 - added PERF_SAMPLE_STACK_USER bit
               - sample_stack_user changed to u32 and
                 added size check
   new patches 1,9,10,20

v5 changes:
   patch 1/19 - having just one enum set of the perf registers
   patch 2/19 - using for_each_set_bit for scanning the mask
              - single regs enum for both 32 and 64 bits versions
              - using regs mask != 0 trigger to trigger the regs dump
   patch 5/19 - adding perf_output_skip so we can skip undumped part of the stack in RB
   patch 6/19 - using stack size != 0 trigger to trigger the stack dump
              - do not zero the memory for non retrieved part of the stack dump
   patch 7/19 - adding exclude_callchain_kernel attribute
   patch 8/19 - this could be taken without the rest of the series

v4 changes:
   - no real change from v3, just rebase
   - v3 patch 06/17 got already merged

v3 changes:
   patch 01/17
   - added HAVE_PERF_REGS config option
   patch 02/17, 04/17
   - regs and stack perf interface is more general now
   patch 06/17
   - unrelated online fix for i386 compilation
   patch 16/17
   - few namespace fixies

---
Adding 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/17 perf: Unified API to record selective sets of arch registers
  02/17 perf: Add ability to attach user level registers dump to sample
  03/17 perf, x86: Add copy_from_user_nmi_nochk for best effort copy
  04/17 perf: Factor __output_copy to be usable with specific copy function
  05/17 perf: Add perf_output_skip function to skip bytes in sample
  06/17 perf: Add ability to attach user stack dump to sample
  07/17 perf: Add attribute to filter out callchains
  08/17 perf, tool: Adding PERF_ATTR_SIZE_VER2 to the header swap check
  09/17 perf, tool: Factor DSO symtab types to generic binary types
  10/17 perf, tool: Add interface to read DSO image data
  11/17 perf, tool: Add interface to arch registers sets
  12/17 perf, tool: Add libunwind dependency for dwarf cfi unwinding
  13/17 perf, tool: Support user regs and stack in sample parsing
  14/17 perf, tool: Support for dwarf cfi unwinding on post processing
  15/17 perf, tool: Support for dwarf mode callchain on perf record
  16/17 perf, tool: Add dso data caching
  17/17 perf, tool: Add dso data caching tests


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 accurate 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 dwarf -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.

Attached patches should work on both x86 and x86_64.

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
    - until full syscall register storage and vdso support
      we could miss some related backtraces 

jirka
---
 arch/Kconfig                                       |    6 +
 arch/x86/Kconfig                                   |    1 +
 arch/x86/include/asm/perf_event.h                  |    2 +
 arch/x86/include/asm/perf_regs.h                   |   33 ++
 arch/x86/include/asm/uaccess.h                     |    2 +
 arch/x86/kernel/Makefile                           |    2 +
 arch/x86/kernel/perf_regs.c                        |   90 +++
 arch/x86/lib/usercopy.c                            |   15 +-
 include/linux/perf_event.h                         |   45 ++-
 include/linux/perf_regs.h                          |   19 +
 kernel/events/callchain.c                          |   25 +-
 kernel/events/core.c                               |  185 +++++++-
 kernel/events/internal.h                           |   69 ++-
 kernel/events/ring_buffer.c                        |   10 +-
 tools/perf/Makefile                                |   46 ++-
 tools/perf/arch/x86/Makefile                       |    3 +
 tools/perf/arch/x86/include/perf_regs.h            |   80 +++
 tools/perf/arch/x86/util/unwind.c                  |  111 ++++
 tools/perf/builtin-record.c                        |  108 ++++-
 tools/perf/builtin-report.c                        |   24 +-
 tools/perf/builtin-script.c                        |   16 +-
 tools/perf/builtin-test.c                          |    8 +-
 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/dso-test-data.c                    |  154 ++++++
 tools/perf/util/event.h                            |   16 +-
 tools/perf/util/evlist.c                           |    8 +
 tools/perf/util/evlist.h                           |    1 +
 tools/perf/util/evsel.c                            |   43 ++-
 tools/perf/util/header.c                           |    3 +
 tools/perf/util/include/linux/compiler.h           |    1 +
 tools/perf/util/map.h                              |    7 +-
 tools/perf/util/perf_regs.h                        |   14 +
 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                          |   97 +++-
 tools/perf/util/session.h                          |   11 +-
 tools/perf/util/symbol.c                           |  436 ++++++++++++---
 tools/perf/util/symbol.h                           |   54 ++-
 tools/perf/util/trace-event-scripting.c            |    3 +-
 tools/perf/util/trace-event.h                      |    5 +-
 tools/perf/util/unwind.c                           |  567 ++++++++++++++++++++
 tools/perf/util/unwind.h                           |   34 ++
 46 files changed, 2210 insertions(+), 196 deletions(-)

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

end of thread, other threads:[~2012-08-03 11:13 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-22 12:14 [PATCHv7 00/17] perf: Add backtrace post dwarf unwind Jiri Olsa
2012-07-22 12:14 ` [PATCH 01/17] perf: Unified API to record selective sets of arch registers Jiri Olsa
2012-07-25 16:12   ` Frederic Weisbecker
2012-07-26 17:51   ` Arnaldo Carvalho de Melo
2012-07-29 22:45     ` Paul Mackerras
2012-07-22 12:14 ` [PATCH 02/17] perf: Add ability to attach user level registers dump to sample Jiri Olsa
2012-07-25 16:13   ` Frederic Weisbecker
2012-07-25 17:00     ` Arnaldo Carvalho de Melo
2012-07-25 17:39   ` Stephane Eranian
2012-07-25 18:27     ` Jiri Olsa
2012-07-26 17:42       ` Stephane Eranian
2012-07-26 17:58         ` Jiri Olsa
2012-07-22 12:14 ` [PATCH 03/17] perf, x86: Add copy_from_user_nmi_nochk for best effort copy Jiri Olsa
2012-07-25 16:11   ` Frederic Weisbecker
2012-07-25 17:16     ` Jiri Olsa
2012-07-25 17:25       ` Frederic Weisbecker
2012-07-25 17:30       ` Jiri Olsa
2012-07-25 17:35         ` Frederic Weisbecker
2012-08-02 18:47   ` Andy Lutomirski
2012-08-03 11:12     ` Jiri Olsa
2012-07-22 12:14 ` [PATCH 04/17] perf: Factor __output_copy to be usable with specific copy function Jiri Olsa
2012-07-22 12:14 ` [PATCH 05/17] perf: Add perf_output_skip function to skip bytes in sample Jiri Olsa
2012-07-22 12:14 ` [PATCH 06/17] perf: Add ability to attach user stack dump to sample Jiri Olsa
2012-07-25 16:36   ` Frederic Weisbecker
2012-07-25 17:03     ` Jiri Olsa
2012-07-22 12:14 ` [PATCH 07/17] perf: Add attribute to filter out callchains Jiri Olsa
2012-07-22 12:14 ` [PATCH 08/17] perf, tool: Adding PERF_ATTR_SIZE_VER2 to the header swap check Jiri Olsa
2012-07-22 12:14 ` [PATCH 09/17] perf, tool: Factor DSO symtab types to generic binary types Jiri Olsa
2012-07-25 19:24   ` [tip:perf/core] perf symbols: " tip-bot for Jiri Olsa
2012-07-22 12:14 ` [PATCH 10/17] perf, tool: Add interface to read DSO image data Jiri Olsa
2012-07-25 19:25   ` [tip:perf/core] perf symbols: " tip-bot for Jiri Olsa
2012-07-22 12:14 ` [PATCH 11/17] perf, tool: Add interface to arch registers sets Jiri Olsa
2012-07-22 12:14 ` [PATCH 12/17] perf, tool: Add libunwind dependency for dwarf cfi unwinding Jiri Olsa
2012-07-22 12:14 ` [PATCH 13/17] perf, tool: Support user regs and stack in sample parsing Jiri Olsa
2012-07-22 12:14 ` [PATCH 14/17] perf, tool: Support for dwarf cfi unwinding on post processing Jiri Olsa
2012-07-25 17:05   ` Frederic Weisbecker
2012-07-25 17:16     ` Arnaldo Carvalho de Melo
2012-07-25 17:21       ` Frederic Weisbecker
2012-07-22 12:14 ` [PATCH 15/17] perf, tool: Support for dwarf mode callchain on perf record Jiri Olsa
2012-07-22 12:14 ` [PATCH 16/17] perf, tool: Add dso data caching Jiri Olsa
2012-07-25 17:11   ` Frederic Weisbecker
2012-07-25 19:26   ` [tip:perf/core] perf symbols: " tip-bot for Jiri Olsa
2012-07-22 12:14 ` [PATCH 17/17] perf, tool: Add dso data caching tests Jiri Olsa
2012-07-25 19:28   ` [tip:perf/core] perf test: " tip-bot for Jiri Olsa
2012-07-25 17:15 ` [PATCHv7 00/17] perf: Add backtrace post dwarf unwind Frederic Weisbecker
2012-07-25 17:19   ` Ingo Molnar

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.