1. 23 Jun, 2016 12 commits
    • Adrian Hunter's avatar
      perf script: Add callindent option · e216708d
      Adrian Hunter authored
      Based on patches from Andi Kleen.
      
      When printing PT instruction traces with perf script it is rather useful
      to see some indentation for the call tree. This patch adds a new
      callindent field to perf script that prints spaces for the function call
      stack depth.
      
      We already have code to track the function call stack for PT, that we
      can reuse with minor modifications.
      
      The resulting output is not quite as nice as ftrace yet, but a lot
      better than what was there before.
      
      Note there are some corner cases when the thread stack gets code
      confused and prints incorrect indentation. Even with that it is fairly
      useful.
      
      When displaying kernel code traces it is recommended to run as root, as
      otherwise perf doesn't understand the kernel addresses properly, and may
      not reset the call stack correctly on kernel boundaries.
      
      Example output:
      
      	sudo perf-with-kcore record eg2 -a -e intel_pt// -- sleep 1
      	sudo perf-with-kcore script eg2 --ns -F callindent,time,comm,pid,sym,ip,addr,flags,cpu --itrace=cre | less
      	...
               swapper     0 [000]  5830.389116586:   call        irq_exit                                                     ffffffff8104d620 smp_call_function_single_interrupt+0x30 => ffffffff8107e720 irq_exit
               swapper     0 [000]  5830.389116586:   call            idle_cpu                                                 ffffffff8107e769 irq_exit+0x49 => ffffffff810a3970 idle_cpu
               swapper     0 [000]  5830.389116586:   return          idle_cpu                                                 ffffffff810a39b7 idle_cpu+0x47 => ffffffff8107e76e irq_exit
               swapper     0 [000]  5830.389116586:   call            tick_nohz_irq_exit                                       ffffffff8107e7bd irq_exit+0x9d => ffffffff810f2fc0 tick_nohz_irq_exit
               swapper     0 [000]  5830.389116919:   call                __tick_nohz_idle_enter                               ffffffff810f2fe0 tick_nohz_irq_exit+0x20 => ffffffff810f28d0 __tick_nohz_idle_enter
               swapper     0 [000]  5830.389116919:   call                    ktime_get                                        ffffffff810f28f1 __tick_nohz_idle_enter+0x21 => ffffffff810e9ec0 ktime_get
               swapper     0 [000]  5830.389116919:   call                        read_tsc                                     ffffffff810e9ef6 ktime_get+0x36 => ffffffff81035070 read_tsc
               swapper     0 [000]  5830.389116919:   return                      read_tsc                                     ffffffff81035084 read_tsc+0x14 => ffffffff810e9efc ktime_get
               swapper     0 [000]  5830.389116919:   return                  ktime_get                                        ffffffff810e9f46 ktime_get+0x86 => ffffffff810f28f6 __tick_nohz_idle_enter
               swapper     0 [000]  5830.389116919:   call                    sched_clock_idle_sleep_event                     ffffffff810f290b __tick_nohz_idle_enter+0x3b => ffffffff810a7380 sched_clock_idle_sleep_event
               swapper     0 [000]  5830.389116919:   call                        sched_clock_cpu                              ffffffff810a738b sched_clock_idle_sleep_event+0xb => ffffffff810a72e0 sched_clock_cpu
               swapper     0 [000]  5830.389116919:   call                            sched_clock                              ffffffff810a734d sched_clock_cpu+0x6d => ffffffff81035750 sched_clock
               swapper     0 [000]  5830.389116919:   call                                native_sched_clock                   ffffffff81035754 sched_clock+0x4 => ffffffff81035640 native_sched_clock
               swapper     0 [000]  5830.389116919:   return                              native_sched_clock                   ffffffff8103568c native_sched_clock+0x4c => ffffffff81035759 sched_clock
               swapper     0 [000]  5830.389116919:   return                          sched_clock                              ffffffff8103575c sched_clock+0xc => ffffffff810a7352 sched_clock_cpu
               swapper     0 [000]  5830.389116919:   return                      sched_clock_cpu                              ffffffff810a7356 sched_clock_cpu+0x76 => ffffffff810a7390 sched_clock_idle_sleep_event
               swapper     0 [000]  5830.389116919:   return                  sched_clock_idle_sleep_event                     ffffffff810a7391 sched_clock_idle_sleep_event+0x11 => ffffffff810f2910 __tick_nohz_idle_enter
      	...
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarAndi Kleen <ak@linux.intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1466689258-28493-4-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e216708d
    • Adrian Hunter's avatar
      perf auxtrace: Add option to feed branches to the thread stack · 50f73637
      Adrian Hunter authored
      In preparation for using the thread stack to print an indent
      representing the stack depth in perf script, add an option to tell
      decoders to feed branches to the thread stack. Add support for that
      option to Intel PT and Intel BTS.
      
      The advantage of using the decoder to feed the thread stack is that it
      happens before branch filtering and so can be used with different itrace
      options (e.g. it still works when only showing calls, even though the
      thread stack needs to see calls and returns). Also it does not conflict
      with using the thread stack to get callchains.
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1466689258-28493-3-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      50f73637
    • Adrian Hunter's avatar
      perf script: Print sample flags more nicely · 055cd33d
      Adrian Hunter authored
      The flags field is synthesized and may have a value when Instruction
      Trace decoding. The flags are "bcrosyiABEx" which stand for branch,
      call, return, conditional, system, asynchronous, interrupt, transaction
      abort, trace begin, trace end, and in transaction, respectively.
      
      Change the display so that known combinations of flags are printed more
      nicely e.g.: "call" for "bc", "return" for "br", "jcc" for "bo", "jmp"
      for "b", "int" for "bci", "iret" for "bri", "syscall" for "bcs",
      "sysret" for "brs", "async" for "by", "hw int" for "bcyi", "tx abrt" for
      "bA", "tr strt" for "bB", "tr end" for "bE".
      
      However the "x" flag will be displayed separately in those cases e.g.
      "jcc (x)" for a condition branch within a transaction.
      
      Example:
      
          perf record -e intel_pt//u ls
          perf script --ns -F comm,cpu,pid,tid,time,ip,addr,sym,dso,symoff,flags
          ...
          ls  3689/3689  [001]  2062.020965237:   jcc          7f06a958847a _dl_sysdep_start+0xfa (/lib/x86_64-linux-gnu/ld-2.19.so) =>     7f06a9588450 _dl_sysdep_start+0xd0 (/lib/x86_64-linux-gnu/ld-2.19.so)
          ls  3689/3689  [001]  2062.020965237:   jmp          7f06a9588461 _dl_sysdep_start+0xe1 (/lib/x86_64-linux-gnu/ld-2.19.so) =>     7f06a95885a0 _dl_sysdep_start+0x220 (/lib/x86_64-linux-gnu/ld-2.19.so)
          ls  3689/3689  [001]  2062.020965237:   jmp          7f06a95885a4 _dl_sysdep_start+0x224 (/lib/x86_64-linux-gnu/ld-2.19.so) =>     7f06a9588470 _dl_sysdep_start+0xf0 (/lib/x86_64-linux-gnu/ld-2.19.so)
          ls  3689/3689  [001]  2062.020965904:   call         7f06a95884c3 _dl_sysdep_start+0x143 (/lib/x86_64-linux-gnu/ld-2.19.so) =>     7f06a9589140 brk+0x0 (/lib/x86_64-linux-gnu/ld-2.19.so)
          ls  3689/3689  [001]  2062.020965904:   syscall      7f06a958914a brk+0xa (/lib/x86_64-linux-gnu/ld-2.19.so) =>                0 [unknown] ([unknown])
          ls  3689/3689  [001]  2062.020966237:   tr strt                 0 [unknown] ([unknown]) =>     7f06a958914c brk+0xc (/lib/x86_64-linux-gnu/ld-2.19.so)
          ls  3689/3689  [001]  2062.020966237:   return       7f06a9589165 brk+0x25 (/lib/x86_64-linux-gnu/ld-2.19.so) =>     7f06a95884c8 _dl_sysdep_start+0x148 (/lib/x86_64-linux-gnu/ld-2.19.so)
          ls  3689/3689  [001]  2062.020966237:   jcc          7f06a95884d7 _dl_sysdep_start+0x157 (/lib/x86_64-linux-gnu/ld-2.19.so) =>     7f06a95885f0 _dl_sysdep_start+0x270 (/lib/x86_64-linux-gnu/ld-2.19.so)
          ls  3689/3689  [001]  2062.020966237:   call         7f06a95885f0 _dl_sysdep_start+0x270 (/lib/x86_64-linux-gnu/ld-2.19.so) =>     7f06a958ac50 strlen+0x0 (/lib/x86_64-linux-gnu/ld-2.19.so)
          ls  3689/3689  [001]  2062.020966237:   jcc          7f06a958ac6e strlen+0x1e (/lib/x86_64-linux-gnu/ld-2.19.so) =>     7f06a958ac60 strlen+0x10 (/lib/x86_64-linux-gnu/ld-2.19.so)
          ...
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarAndi Kleen <ak@linux.intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1466689258-28493-2-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      055cd33d
    • Arnaldo Carvalho de Melo's avatar
      perf intlist: Rename for_each() macros to for_each_entry() · 10daf4d0
      Arnaldo Carvalho de Melo authored
      To match the semantics for list.h in the kernel, that are the
      interface we use in them.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-mdp1heu9xjjc12zebh91232l@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      10daf4d0
    • Arnaldo Carvalho de Melo's avatar
      perf rb_resort: Rename for_each() macros to for_each_entry() · 98a91837
      Arnaldo Carvalho de Melo authored
      To match the semantics for list.h in the kernel, that are the
      interface we use in them.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-iaxuq2yu43mtb504j96q0axs@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      98a91837
    • Arnaldo Carvalho de Melo's avatar
      perf tools: Rename strlist_for_each() macros to for_each_entry() · 602a1f4d
      Arnaldo Carvalho de Melo authored
      To match the semantics for list.h in the kernel, that are the
      interface we use in them.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-0b5i2ki9c3di6706fxpticsb@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      602a1f4d
    • Arnaldo Carvalho de Melo's avatar
      perf evlist: Rename for_each() macros to for_each_entry() · e5cadb93
      Arnaldo Carvalho de Melo authored
      To match the semantics for list.h in the kernel, that are used to
      implement those macros.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-qbcjlgj0ffxquxscahbpddi3@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e5cadb93
    • He Kuang's avatar
      perf unwind: Fix wrongly used regs for aarch64 unwind · 3bd03c95
      He Kuang authored
      By default, "unwind-libunwind-local.c" gets SP/IP register number
      according to the host platform, for remote unwind, we should use
      register number for target platform. Fix this by define
      LIBUNWIND_ARCH_REG_SP/IP in the wrapper file of aarch64 platform.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1466578626-92406-4-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3bd03c95
    • He Kuang's avatar
      perf unwind: Fix wrongly used regs for x86_32 unwind · 5dafea09
      He Kuang authored
      By default, "unwind-libunwind-local.c" gets SP/IP register number
      according to the host platform, for remote unwind, we should use
      register number for target platform. Fix this by define
      LIBUNWIND_ARCH_REG_SP/IP in the wrapper file of x86_32 platform.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1466578626-92406-3-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5dafea09
    • He Kuang's avatar
      perf unwind: Change macro names of perf register · 78ff1d6d
      He Kuang authored
      Use macro name prefixed with "LIBUNWIND_ARCH" for better understanding
      that the regs used by callbacks of libunwind are arch specific. The real
      regs used should be defined in the wrapper file of
      "unwind-libunwind-local.c" for each supported arch.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1466578626-92406-2-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      78ff1d6d
    • He Kuang's avatar
      perf tools: Find right DSO taking into account if binary is 32 or 64-bit · 76c588f1
      He Kuang authored
      There's a problem in machine__findnew_vdso(), vdso buildid generated by a
      32-bit machine stores it with the name 'vdso', but when processing buildid on a
      64-bit machine with the same 'perf.data', perf will search for vdso named as
      'vdso32' and get failed.
      
      This patch tries to find the existing dsos in machine->dsos by thread dso_type.
      64-bit thread tries to find vdso with name 'vdso', because all 64-bit vdso is
      named as that. 32-bit thread first tries to find vdso with name 'vdso32' if
      this thread was run on 64-bit machine, if failed, then it tries 'vdso' which
      indicates that the thread was run on 32-bit machine when recording.
      
      Committer note:
      
      Additional explanation by Adrian Hunter:
      
      We match maps to builds ids using the file name - consider
      machine__findnew_[v]dso() called in map__new().  So in the context of a perf
      data file, we consider the file name to be unique.
      
      A vdso map does not have a file name - all we know is that it is vdso.  We look
      at the thread to tell if it is 32-bit, 64-bit or x32.  Then we need to get the
      build id which has been recorded using short name "[vdso]" or "[vdso32]" or
      "[vdsox32]".
      
      The problem is that on a 32-bit machine, we use the name "[vdso]".  If you take
      a 32-bit perf data file to a 64-bit machine, it gets hard to figure out if
      "[vdso]" is 32-bit or 64-bit.
      
      This patch solves that problem.
      
       ----
      
      This also merges a followup patch fixing a problem introduced by the
      original submission of this patch, that would crash 'perf record' when
      recording samples for a 32-bit app on a 64-bit system.
      Signed-off-by: default avatarHe Kuang <hekuang@huawei.com>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1463475894-163531-1-git-send-email-hekuang@huawei.com
      Link: http://lkml.kernel.org/r/1466578626-92406-6-git-send-email-hekuang@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      76c588f1
    • Taeung Song's avatar
      perf config: Move config declarations from util/cache.h to util/config.h · 41840d21
      Taeung Song authored
      Lately util/config.h has been added but util/cache.h has declarations of
      functions and a global variable for config features.
      
      To manage codes about configuration at one spot, move them to
      util/config.h and let source files that need config features include
      config.h And if the source files that included previous cache.h need
      only config.h, remove including cache.h.
      Signed-off-by: default avatarTaeung Song <treeze.taeung@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1466672119-4852-2-git-send-email-treeze.taeung@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      41840d21
  2. 22 Jun, 2016 14 commits
  3. 21 Jun, 2016 9 commits
  4. 16 Jun, 2016 1 commit
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-20160615' of... · 02469a95
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-20160615' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      User visible changes:
      
      - Add --ldlat option to 'perf mem' to specify load latency for loads
        event (e.g. cpu/mem-loads/ ) (Jiri Olsa)
      
      Build fixes:
      
      - Fix libunwind related compile error for static cross build (He Kuang)
      
      Infrastructure changes:
      
      - UI refactorings to support headers with multiple lines, non-evsel
        hists browsers, toggle showing callchains, etc (Jiri Olsa)
      
      - More prep work for caching probe definitions, paving the way
        for supporting SDT (Statically Defined Traces) userspace probes (Masami Hiramatsu)
      
      - Handle NULL at perf_config_set__delete() (Taeung Song)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      02469a95
  5. 15 Jun, 2016 4 commits