1. 18 12月, 2015 11 次提交
  2. 17 12月, 2015 5 次提交
  3. 15 12月, 2015 2 次提交
    • N
      perf record: Add record.build-id config option · 7a29c087
      Namhyung Kim 提交于
      Post processing at 'perf record' takes a long time on big machines.
      
      What it does is to find the build-id of binaries found in the event
      stream, so that it can make sure, at 'report' time, that the symtabs (be
      it ELF, kallsyms, etc) being used to resolve symbols are the ones
      matching the binaries found at 'record' time.
      
      Sometimes we just want to skip this processing of events at the end of
      the session to get quicker results, making sure the binaries haven't
      changed from 'record' to 'report' time.
      
      Add a new config option to control this behavior.
      
      The record.build-id config variable can have one of the following
      values:
      
       - cache: post-process data and save/update the binaries into the
                build-id cache (in ~/.debug).  This is the default.
       - no-cache: post-process the data but not update the build-id cache.
                   Same effect as using the -N option.
       - skip: skip post-processing and do not update the cache.
               Same effect as using the -B option.
      Reported-and-Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Taeung Song <treeze.taeung@gmail.com>
      Link: http://lkml.kernel.org/r/1450144196-22957-1-git-send-email-namhyung@kernel.org
      [ Added some more text to the documentation ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7a29c087
    • H
      perf record: Support custom vmlinux path · 7efe0e03
      He Kuang 提交于
      Make perf-record command support --vmlinux option if BPF_PROLOGUE is on.
      
      'perf record' needs vmlinux as the source of DWARF info to generate
      prologue for BPF programs, so path of vmlinux should be specified.
      
      Short name 'k' has been taken by 'clockid'. This patch skips the short
      option name and uses '--vmlinux' for vmlinux path.
      
      Documentation is also updated.
      
      Test result:
      
      In a production (or broken) environment:
       (by:
        # rm -rf ~/.debug/
        # mv /lib/modules/`uname -r`/build/vmlinux /tmp/
       )
      
       # ./perf record -e ./test_bpf_base.c ls
       Failed to find the path for kernel: No such file or directory
       event syntax error: './test_bpf_base.c'
                            \___ You need to check probing points in BPF file
       ...
      
       # ./perf record --vmlinux /tmp/vmlinux -e ./test_bpf_base.c ls
       ...
       [ perf record: Woken up 1 times to write data ]
       [ perf record: Captured and wrote 0.011 MB perf.data ]
      
      Help messages when build with NO_LIBBPF:
      
       # ./perf record -h
              --transaction     sample transaction flags (special events only)
              --vmlinux <file>  vmlinux pathname
                                (not built-in because NO_LIBBPF=1)
       # ./perf record --vmlinux /tmp/vmlinux ls /
        Warning: option `vmlinux' is being ignored because NO_LIBBPF=1
       ...
       [ perf record: Woken up 1 times to write data ]
       [ perf record: Captured and wrote 0.011 MB perf.data (11 samples) ]
      
      Help messages when build with NO_DWARF:
      
       # ./perf record -h
              --transaction     sample transaction flags (special events only)
              --vmlinux <file>  vmlinux pathname
                                (not built-in because NO_DWARF=1)
      Signed-off-by: NHe Kuang <hekuang@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1450089563-122430-15-git-send-email-wangnan0@huawei.comSigned-off-by: NWang Nan <wangnan0@huawei.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7efe0e03
  4. 14 12月, 2015 14 次提交
  5. 11 12月, 2015 8 次提交
    • W
      perf tools: Clear struct machine during machine__init() · 93b0ba3c
      Wang Nan 提交于
      There are so many test cases use stack allocated 'struct machine'.
      Including:
        test__hists_link
        test__hists_filter
        test__mmap_thread_lookup
        test__thread_mg_share
        test__hists_output
        test__hists_cumulate
      
      Also, in non-test code (for example, machine__new_host()) there are
      code use 'malloc()' to alloc struct machine.
      
      These are dangerous operations, cause some tests fail or hung in
      machines__exit(). For example, in
      
       machines__exit ->
         machine__destroy_kernel_maps ->
           map_groups__remove ->
             maps__remove ->
               pthread_rwlock_wrlock
      
      a incorrectly initialized lock causes unintended behavior.
      
      This patch memset(0) that structure in machine__init() to ensure all
      fields in 'struct machine' are initialized to zero.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1449541544-67621-17-git-send-email-wangnan0@huawei.com
      [ Use memset, see 'man bzero' ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      93b0ba3c
    • W
      perf script: Add support for PERF_TYPE_BREAKPOINT · 27cfef00
      Wang Nan 提交于
      Useful for getting stack traces for hardware breakpoint events.
      
      Test result:
      
      Before this patch:
       # ~/perf record -g -e mem:0x600980 ./sample
       [ perf record: Woken up 1 times to write data ]
       [ perf record: Captured and wrote 0.011 MB perf.data (12 samples) ]
      
       # ~/perf script
      
       # ~/perf script -F comm,tid,pid,time,event,ip,sym,dso
       sample 22520/22520 97457.836294: mem:0x600980:
                5a4ad8 __clear_user (/lib/modules/4.3.0-rc4+/build/vmlinux)
       ...
                3f41ba sys_execve (/lib/modules/4.3.0-rc4+/build/vmlinux)
                979395 return_from_execve (/lib/modules/4.3.0-rc4+/build/vmlinux)
          7f1b59719cf7 [unknown] ([unknown])
      
       sample 22520/22520 97457.836648: mem:0x600980:
                   532 main (/home/w00229757/DataBreakpoints/sample)
                 21bd5 __libc_start_main (/tmp/oxygen_root-root/lib64/libc-2.18.so)
       ...
      
      After this patch:
       # ~/perf script
       sample 22520 97457.836294: mem:0x600980:
                         5a4ad8 __clear_user (/lib/modules/4.3.0-rc4+/build/vmlinux)
       ...
                         3f41ba sys_execve (/lib/modules/4.3.0-rc4+/build/vmlinux)
                         979395 return_from_execve (/lib/modules/4.3.0-rc4+/build/vmlinux)
                   7f1b59719cf7 [unknown] ([unknown])
      
       sample 22520 97457.836648: mem:0x600980:
                            532 main (/home/w00229757/DataBreakpoints/sample)
                          21bd5 __libc_start_main (/tmp/oxygen_root-root/lib64/libc-2.18.so)
      
      Committer note:
      
      So, further testing, lets do it for a kernel global variable,
      tcp_hashinfo:
      
        # grep -w tcp_hashinfo /proc/kallsyms
        ffffffff8202fc00 B tcp_hashinfo
        #
      
      Note: allow specifying mem:tcp_hashinfo:
      
        # perf record -g -e mem:0xffffffff81c65ac0 -a
        ^C[ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.790 MB perf.data ]
        #
        # perf evlist
        mem:0xffffffff8202fc00
        # perf evlist -v
        mem:0xffffffff8202fc00: type: 5, size: 112, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CALLCHAIN|CPU, disabled: 1, inherit: 1, mmap: 1, comm: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, bp_type: 3, { bp_addr, config1 }: 0xffffffff8202fc00, { bp_len, config2 }: 0x4
        #
      
      Then, after this patch:
      
        # perf script
        swapper 0 [000] 171036.986988: mem:0xffffffff8202fc00:
          8a0fb5 __inet_lookup_established (/lib/modules/4.3.0+/build/vmlinux)
          8bc09d tcp_v4_early_demux (/lib/modules/4.3.0+/build/vmlinux)
          896def ip_rcv_finish (/lib/modules/4.3.0+/build/vmlinux)
          8976c2 ip_rcv (/lib/modules/4.3.0+/build/vmlinux)
          855eba __netif_receive_skb_core (/lib/modules/4.3.0+/build/vmlinux)
          8565d8 __netif_receive_skb (/lib/modules/4.3.0+/build/vmlinux)
          8572a8 process_backlog (/lib/modules/4.3.0+/build/vmlinux)
          856b11 net_rx_action (/lib/modules/4.3.0+/build/vmlinux)
          2a284b __do_softirq (/lib/modules/4.3.0+/build/vmlinux)
          2a2ba3 irq_exit (/lib/modules/4.3.0+/build/vmlinux)
          96b7a4 do_IRQ (/lib/modules/4.3.0+/build/vmlinux)
          969807 ret_from_intr (/lib/modules/4.3.0+/build/vmlinux)
          804c27 cpuidle_enter (/lib/modules/4.3.0+/build/vmlinux)
          2ded22 call_cpuidle (/lib/modules/4.3.0+/build/vmlinux)
          2defb6 cpu_startup_entry (/lib/modules/4.3.0+/build/vmlinux)
          95d5bc rest_init (/lib/modules/4.3.0+/build/vmlinux)
         1163ffa start_kernel ([kernel.vmlinux].init.text)
         11634d7 x86_64_start_reservations ([kernel.vmlinux].init.text)
         1163623 x86_64_start_kernel ([kernel.vmlinux].init.text)
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1449541544-67621-16-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      27cfef00
    • W
      perf data: Add u32_hex data type · 26812d46
      Wang Nan 提交于
      Add hexadecimal u32 to base data type, which is useful for raw output
      because raw data is u32 aligned.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1449541544-67621-12-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      26812d46
    • N
      perf top: Cleanup condition in perf_top__record_precise_ip() · beefb8d0
      Namhyung Kim 提交于
      The 'he' cannot be NULL since it's caller hist_iter__top_callback() is
      called only if iter->he is not NULL (see hist_entry_iter__add).  So
      setting 'sym' before the condition to simplify the code.
      
      Also make it clearer that the top->symbol_filter_entry check is only
      meaningful on stdio mode (i.e. when use_browser is 0).
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1449802616-16170-4-git-send-email-namhyung@kernel.org
      [ Complete the simplification replacing one more he->ms.sym with sym ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      beefb8d0
    • N
      perf top: Fix annotation on --stdio · 448f13b2
      Namhyung Kim 提交于
      The ui__has_annotation() inside perf_top__record_precise_ip() should be
      removed since it returns true only for TUI (and when sort key has
      symbol).  However the 'perf top --stdio' also supports annotation for a
      symbol which was specified by 's' key action.
      
      Actually it already does the necessary checks before calling the
      function.  So it's ok to get rid of the check here.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1449802616-16170-3-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      448f13b2
    • N
      perf top: Access hists->lock only if needed · 151ee834
      Namhyung Kim 提交于
      The perf_top__record_precise_ip() releases and regrabs the
      he->hists->lock because it can sleep if there's an error.  But it should
      be done conditionally as it slows down the fast path.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1449802616-16170-2-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      151ee834
    • N
      perf top: Do not convert address for perf_top__record_precise_ip() · 64226bcf
      Namhyung Kim 提交于
      We call map->unmap_ip() before the function and call map->map_ip()
      inside the function.  This is meaningless and look strange since only
      one of the two checks 'map'.  Let's use al->addr directly.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1449802616-16170-1-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      64226bcf
    • M
      perf symbols: Fix dso__load_sym to put dso · e7a7865c
      Masami Hiramatsu 提交于
      Fix dso__load_sym to put dso because dsos__add already got it.
      
      Refcnt debugger explain the problem:
        ----
        ==== [0] ====
        Unreclaimed dso: 0x19dd200
        Refcount +1 => 1 at
          ./perf(dso__new+0x1ff) [0x4a62df]
          ./perf(dso__load_sym+0xe89) [0x503509]
          ./perf(dso__load_vmlinux+0xbf) [0x4aa77f]
          ./perf(dso__load_vmlinux_path+0x8c) [0x4aa8dc]
          ./perf() [0x50539a]
          ./perf(convert_perf_probe_events+0xd79) [0x50ad39]
          ./perf() [0x45600f]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f74dd0efaf5]
          ./perf() [0x4220a9]
        Refcount +1 => 2 at
          ./perf(dso__get+0x34) [0x4a65f4]
          ./perf(map__new2+0x76) [0x4be216]
          ./perf(dso__load_sym+0xee1) [0x503561]
          ./perf(dso__load_vmlinux+0xbf) [0x4aa77f]
          ./perf(dso__load_vmlinux_path+0x8c) [0x4aa8dc]
          ./perf() [0x50539a]
          ./perf(convert_perf_probe_events+0xd79) [0x50ad39]
          ./perf() [0x45600f]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f74dd0efaf5]
          ./perf() [0x4220a9]
        Refcount +1 => 3 at
          ./perf(dsos__add+0xf3) [0x4a6bc3]
          ./perf(dso__load_sym+0xfc1) [0x503641]
          ./perf(dso__load_vmlinux+0xbf) [0x4aa77f]
          ./perf(dso__load_vmlinux_path+0x8c) [0x4aa8dc]
          ./perf() [0x50539a]
          ./perf(convert_perf_probe_events+0xd79) [0x50ad39]
          ./perf() [0x45600f]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f74dd0efaf5]
          ./perf() [0x4220a9]
        Refcount -1 => 2 at
          ./perf(dso__put+0x2f) [0x4a664f]
          ./perf(map_groups__exit+0xb9) [0x4bee29]
          ./perf(machine__delete+0xb0) [0x4b93d0]
          ./perf(exit_probe_symbol_maps+0x28) [0x506718]
          ./perf() [0x45628a]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f74dd0efaf5]
          ./perf() [0x4220a9]
        Refcount -1 => 1 at
          ./perf(dso__put+0x2f) [0x4a664f]
          ./perf(machine__delete+0xfe) [0x4b941e]
          ./perf(exit_probe_symbol_maps+0x28) [0x506718]
          ./perf() [0x45628a]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f74dd0efaf5]
          ./perf() [0x4220a9]
        ----
      So, in the dso__load_sym, dso is gotten 3 times, by dso__new,
      map__new2, and dsos__add. The last 2 is actually released by
      map_groups and machine__delete correspondingly. However, the
      first reference by dso__new, is never released.
      
      Committer note:
      
      Changed the place where the reference count is dropped to:
      
      Fix it by dropping it right after creating curr_map, since we know that
      either that operation failed and we need to drop the dso refcount or
      that it succeed and we have it referenced via curr_map->dso.
      
      Then only drop the curr_map refcount after we call dsos__add() to make
      sure we hold a reference to it via curr_map->dso.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20151209021118.10245.49869.stgit@localhost.localdomainSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e7a7865c