1. 10 12月, 2015 7 次提交
  2. 08 12月, 2015 5 次提交
  3. 07 12月, 2015 1 次提交
    • M
      perf buildid-list: Show running kernel build id fix · 7375e151
      Michael Petlan 提交于
      The --kernel option of perf buildid-list tool should show the running
      kernel buildid.  The functionality has been lost during other changes of
      the related code.
      
      The build_id__sprintf() function should return length of the build-id
      string,  but it was the length of the build-id raw data instead. Due to
      that, some return value checking caused that the final string was not
      printed out.
      
      With this patch the build_id__sprintf() returns the correct value, so
      the --kernel option works again.
      
      Before:
      
      	# perf buildid-list --kernel
      	#
      
      After:
      
      	# perf buildid-list --kernel
      	972c1edab5bdc06cc224af45d510af662a3c6972
      	#
      Signed-off-by: NMichael Petlan <mpetlan@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      LPU-Reference: 1448632089.24573.114.camel@redhat.com
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7375e151
  4. 28 11月, 2015 4 次提交
    • W
      perf bpf: Rename bpf config to program config · 0bb93490
      Wang Nan 提交于
      Following patches are going to introduce BPF object level configuration
      to enable setting values into BPF maps. To avoid confusion, this patch
      renames existing 'config' in bpf-loader.c to 'program config'. Following
      patches would introduce 'object config'.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@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/1448614067-197576-4-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0bb93490
    • N
      perf hists: Do not skip elided fields when processing samples · e72655d9
      Namhyung Kim 提交于
      If user gives a filter, perf marks the corresponding column elided and
      omits the output.  But it should process and aggregates samples using
      the field, otherwise samples will be aggregated as if the column was not
      there resulted in incorrect output.
      
      For example, I'd like to set a filter on native_write_msr_safe.  The
      original overhead of the function is negligible.
      
        $ perf report | grep native_write_msr_safe
            0.00%  swapper  [kernel.vmlinux]  native_write_msr_safe
            0.00%  perf     [kernel.vmlinux]  native_write_msr_safe
      
      However adding -S option gives different output.
      
        $ perf report -S native_write_msr_safe --percentage absolute | \
        > grep -e swapper -e perf
           51.47%  swapper  [kernel.vmlinux]
            4.14%  perf     [kernel.vmlinux]
      
      Since it aggregated samples using comm and dso only.  In fact, the above
      values are same when it sorts with -s comm,dso.
      
        $ perf report -s comm,dso | grep -e swapper -e perf
           51.47%  swapper  [kernel.vmlinux]
            4.14%  perf     [kernel.vmlinux]
      
      This resulted in TUI failure with -ERANGE since it tries to increase
      sample hit count for annotation with wrong symbols due to incorrect
      aggregation.
      
      This patch fixes it not to skip elided fields when comparing samples in
      order to insert them to the hists.
      
      Commiter note:
      
      After the patch, with a different workloads:
      
        # perf report --show-total-period -S native_write_msr_safe --stdio
        #
        # symbol: native_write_msr_safe
        #
        # Samples: 455  of event 'cycles:pp'
        # Event count (approx.): 134787489
        #
        # Overhead Period Command         Shared Object
        # ........ ...... ............... ................
        #
             0.22% 293081 qemu-system-x86 [vmlinux]
             0.19% 255914 swapper         [vmlinux]
             0.00%   2054 Timer           [vmlinux]
             0.00%   1021 firefox         [vmlinux]
             0.00%      2 perf            [vmlinux]
      
        # perf report --show-total-period | grep native_write_msr_safe
        Failed to open /tmp/perf-14838.map, continuing without symbols
             0.22% 293081 qemu-system-x86 [vmlinux]  [k] native_write_msr_safe
             0.19% 255914 swapper         [vmlinux]  [k] native_write_msr_safe
             0.00%   2054 Timer           [vmlinux]  [k] native_write_msr_safe
             0.00%   1021 firefox         [vmlinux]  [k] native_write_msr_safe
             0.00%      2 perf            [vmlinux]  [k] native_write_msr_safe
        #
      Reported-by: NIngo Molnar <mingo@kernel.org>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      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/1448645559-31167-2-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e72655d9
    • A
      perf list: Robustify event printing routine · e37df6c7
      Arnaldo Carvalho de Melo 提交于
      When a43eec30 ("bpf: introduce bpf_perf_event_output() helper") added
      PERF_COUNT_SW_BPF_OUTPUT we ended up with a new entry in the event_symbols_sw
      array that wasn't initialized, thus set to NULL, fix print_symbol_events()
      to check for that case so that we don't crash if this happens again.
      
        (gdb) bt
        #0  __match_glob (ignore_space=false, pat=<optimized out>, str=<optimized out>) at util/string.c:198
        #1  strglobmatch (str=<optimized out>, pat=pat@entry=0x7fffffffe61d "stall") at util/string.c:252
        #2  0x00000000004993a5 in print_symbol_events (type=1, syms=0x872880 <event_symbols_sw+160>, max=11, name_only=false, event_glob=0x7fffffffe61d "stall")
            at util/parse-events.c:1615
        #3  print_events (event_glob=event_glob@entry=0x7fffffffe61d "stall", name_only=false) at util/parse-events.c:1675
        #4  0x000000000042c79e in cmd_list (argc=1, argv=0x7fffffffe390, prefix=<optimized out>) at builtin-list.c:68
        #5  0x00000000004788a5 in run_builtin (p=p@entry=0x871758 <commands+120>, argc=argc@entry=2, argv=argv@entry=0x7fffffffe390) at perf.c:370
        #6  0x0000000000420ab0 in handle_internal_command (argv=0x7fffffffe390, argc=2) at perf.c:429
        #7  run_argv (argv=0x7fffffffe110, argcp=0x7fffffffe11c) at perf.c:473
        #8  main (argc=2, argv=0x7fffffffe390) at perf.c:588
        (gdb) p event_symbols_sw[PERF_COUNT_SW_BPF_OUTPUT]
        $4 = {symbol = 0x0, alias = 0x0}
        (gdb)
      
      A patch to robustify perf to not segfault when the next counter gets added in
      the kernel will follow this one.
      Reported-by: NIngo Molnar <mingo@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-57wysblcjfrseb0zg5u7ek10@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e37df6c7
    • A
      perf list: Add support for PERF_COUNT_SW_BPF_OUT · bae9cc41
      Arnaldo Carvalho de Melo 提交于
      When PERF_COUNT_SW_BPF_OUTPUT was added to the kernel we should've
      added it to tools/perf, where it is used just to list events.
      
      This ended up causing a segfault in commands like "perf list stall".
      
      Fix it by adding that new software counter.
      
      A patch to robustify perf to not segfault when the next counter gets
      added in the kernel will follow this one.
      Reported-by: NIngo Molnar <mingo@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-uya354upi3eprsey6mi5962d@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bae9cc41
  5. 27 11月, 2015 8 次提交
    • M
      perf buildid-list: Show running kernel build id fix · c4e07949
      Michael Petlan 提交于
      The --kernel option of perf buildid-list tool should show the running
      kernel buildid.  The functionality has been lost during other changes of
      the related code.
      
      The build_id__sprintf() function should return length of the build-id
      string,  but it was the length of the build-id raw data instead. Due to
      that, some return value checking caused that the final string was not
      printed out.
      
      With this patch the build_id__sprintf() returns the correct value, so
      the --kernel option works again.
      
      Before:
      
      	# perf buildid-list --kernel
      	#
      
      After:
      
      	# perf buildid-list --kernel
      	972c1edab5bdc06cc224af45d510af662a3c6972
      	#
      Signed-off-by: NMichael Petlan <mpetlan@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      LPU-Reference: 1448632089.24573.114.camel@redhat.com
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c4e07949
    • J
      perf evlist: Display WEIGHT sample type bit · dcdd184b
      Jiri Olsa 提交于
      Adding WIEGHT bit_name call to display sample_type properly.
      
        $ perf evlist -v
        cpu/mem-loads/pp: ...SNIP... sample_type: IP|TID|TIME|ADDR|ID|CPU|DATA_SRC|WEIGHT ...
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1448465815-27404-2-git-send-email-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      dcdd184b
    • E
      perf symbols: Add the path to vmlinux.debug · f55ae954
      Ekaterina Tumanova 提交于
      Currently when debuginfo is separated to vmlinux.debug, it's contents
      get ignored. Let's change that and add it to the vmlinux_path list.
      Signed-off-by: NEkaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Acked-by: NAlexander Yarygin <yarygin@linux.vnet.ibm.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1448469166-61363-3-git-send-email-tumanova@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f55ae954
    • E
      perf symbols: Refactor vmlinux_path__init() to ease path additions · aac48647
      Ekaterina Tumanova 提交于
      Refactor vmlinux_path__init() to ease subsequent additions of new
      vmlinux locations.
      Signed-off-by: NEkaterina Tumanova <tumanova@linux.vnet.ibm.com>
      Acked-by: NAlexander Yarygin <yarygin@linux.vnet.ibm.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1448469166-61363-2-git-send-email-tumanova@linux.vnet.ibm.com
      [ Rename vmlinux_path__update() to vmlinux_path__add() ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      aac48647
    • Y
      perf tools: Correctly identify anon_hugepage when generating map (v2) · b2be5451
      Yannick Brosseau 提交于
      When parsing /proc/xxx/maps, the sscanf in perf_event__synthesize_mmap_events
      truncate the map name at the space in "/anon_hugepage (deleted)".
      
      is_anon_memory() then only receives the string "/anon_hugepage" and does
      not detect it.  We change is_anon_memory() to only compare the first
      part of the string, effectively ignoring if " (deleted)" is there.
      Signed-off-by: NYannick Brosseau <scientist@fb.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Joshua Zhu <zhu.wen-jie@hp.com>
      Cc: kernel-team@fb.com
      Link: http://lkml.kernel.org/r/1448538152-2898-1-git-send-email-scientist@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b2be5451
    • W
      perf machine: Adjust dso->long_name for offline module · c03d5184
      Wang Nan 提交于
      Something unexpected may happen if copy statically linked perf to a
      production environment:
      
        # ./perf probe -m ./mymodule.ko my_func
        [mymodule] with build id 326ab42550ef3d24944f53c817533728367effeb not found, continuing without symbols
        Failed to find symbol my_func in /home/wangnan/kmodule/mymodule.ko
          Error: Failed to add events.
        # ./perf buildid-cache -a ./mymodule.ko
        # ./perf probe -m ./mymodule.ko my_func
        Added new event:
          probe:my_func        (on my_func in /home/wangnan/kmodule/mymodule.ko)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:my_func -aR sleep 1
      
      Where:
      
        # ldd ./perf
       	not a dynamic executable
        # strace -e open ./perf probe -m ./mymodule.ko my_func
        ...
        open("/home/wangnan/kmodule/mymodule.ko", O_RDONLY) = 3
        open("/home/wangnan/kmodule/../lib64/elfutils/libebl_x86_64.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
        ...
        open("/lib64/tls/libebl_x86_64.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
        open("/lib64/libebl_x86_64.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
        open("/usr/lib64/tls/libebl_x86_64.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
        open("/usr/lib64/libebl_x86_64.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
        open("[mymodule]", O_RDONLY)            = -1 ENOENT (No such file or directory)
        open("/home/wangnan/.debug/.build-id/32/6ab42550ef3d24944f53c817533728367effeb", O_RDONLY) = -1 ENOENT (No such file or directory)
        open("[mymodule]", O_RDONLY)            = -1 ENOENT (No such file or directory)
      
      In the above example, probe fails before we put the module into
      buildid-cache. However, user would expect it success in both case
      because perf is able to find probe points actually.
      
      The reason is because perf won't utilize module's full path if it failed
      to open debuginfo. In:
      
           convert_to_probe_trace_events ->
              find_probe_trace_events_from_map ->
                  get_target_map ->
                      kernel_get_module_map ->
                          machine__findnew_module_map ->
                              map_groups__find_by_name
      
      map_groups__find_by_name() is able to find the map of that module, but
      this information is found from /proc/module before it knows the real
      path of the offline module. Therefore, the map->dso->long_name is set to
      something like '[mymodule]', which prevent dso__load() find the real
      path of the module file.
      
      In another aspect, if dso__load() can get the offline module through
      buildid cache, it can read symble table from that ko. Even if debuginfo
      is not available, 'perf probe' can success if the '.symtab' can be
      found.
      
      This patch improves machine__findnew_module_map(): when dso->long_name
      is leading with '[' (doesn't find path of module when parsing
      /proc/modules), fixes it by dso__set_long_name(), so following
      dso__load() is possible to find the symbol table.
      
      This patch won't interfere with buildid matching. Here is the test
      result:
      
        # ./perf probe -m ./mymodule.ko my_func
        Added new event:
          probe:my_func        (on my_func in /home/wangnan/kmodule/mymodule.ko)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:my_func -aR sleep 1
      
        # ./perf probe -d '*'
        Removed event: probe:my_func
        # mv ./mymodule.{ko,.bak}
        # mv ./moduleb.ko mymodule.ko
        # ./perf probe -m ./mymodule.ko my_func
        /home/wangnan/kmodule/mymodule.ko with build id 326ab42550ef3d24944f53c817533728367effeb not found, continuing without symbols
        Failed to find symbol my_func in /home/wangnan/kmodule/mymodule.ko
          Error: Failed to add events.
      
        # ./perf probe -v -m ./mymodule.ko my_func
        probe-definition(0): my_func
        symbol:my_func file:(null) line:0 offset:0 return:0 lazy:(null)
        0 arguments
        Could not open debuginfo. Try to use symbols.
        symsrc__init: build id mismatch for /home/wangnan/kmodule/mymodule.ko.
        /home/wangnan/kmodule/mymodule.ko with build id 326ab42550ef3d24944f53c817533728367effeb not found, continuing without symbols
        Failed to find symbol my_func in /home/wangnan/kmodule/mymodule.ko
          Error: Failed to add events. Reason: No such file or directory (Code: -2)
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      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/1448510397-187965-1-git-send-email-wangnan0@huawei.com
      [ Renamed adjust_dso_long_name() do dso__adjust_kmod_long_name() ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c03d5184
    • N
      perf top: Fix freeze on --call-graph flat/folded · 0356218a
      Namhyung Kim 提交于
      The callchain rbtree is rebuilt periodically, so it needs to
      reinitialize the root everytime.  Otherwise it can be stuck in the
      rbtree insertion with stale pointers.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1448521700-32062-1-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0356218a
    • N
      perf callchain: Honor hide_unresolved · b49a8fe5
      Namhyung Kim 提交于
      If user requested to hide unresolved entries, skip unresolved callchains
      as well as hist entries.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1448521700-32062-3-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b49a8fe5
  6. 26 11月, 2015 1 次提交
  7. 24 11月, 2015 4 次提交
  8. 20 11月, 2015 10 次提交
    • N
      perf hists browser: Support flat callchains · 4b3a3212
      Namhyung Kim 提交于
      The flat callchain mode is to print all chains in a single, simple
      hierarchy so make it easy to see.
      
      Currently perf report --tui doesn't show flat callchains properly.  With
      flat callchains, only leaf nodes are added to the final rbtree so it
      should show entries in parent nodes.  To do that, add parent_val list to
      struct callchain_node and show them along with the (normal) val list.
      
      For example, consider following callchains with '-g graph'.
      
        $ perf report -g graph
        - 39.93%  swapper  [kernel.vmlinux]  [k] intel_idle
             intel_idle
             cpuidle_enter_state
             cpuidle_enter
             call_cpuidle
           - cpu_startup_entry
                28.63% start_secondary
              - 11.30% rest_init
                   start_kernel
                   x86_64_start_reservations
                   x86_64_start_kernel
      
      Before:
        $ perf report -g flat
        - 39.93%  swapper  [kernel.vmlinux]  [k] intel_idle
             28.63% start_secondary
           - 11.30% rest_init
                start_kernel
                x86_64_start_reservations
                x86_64_start_kernel
      
      After:
        $ perf report -g flat
        - 39.93%  swapper  [kernel.vmlinux]  [k] intel_idle
           - 28.63% intel_idle
                cpuidle_enter_state
                cpuidle_enter
                call_cpuidle
                cpu_startup_entry
                start_secondary
           - 11.30% intel_idle
                cpuidle_enter_state
                cpuidle_enter
                call_cpuidle
                cpu_startup_entry
                start_kernel
                x86_64_start_reservations
                x86_64_start_kernel
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NBrendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1447047946-1691-8-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4b3a3212
    • N
      perf report: Add callchain value option · f2af0086
      Namhyung Kim 提交于
      Now -g/--call-graph option supports how to display callchain values.
      Possible values are 'percent', 'period' and 'count'.  The percent is
      same as before and it's the default behavior.  The period displays the
      raw period value rather than the percentage.  The count displays the
      number of occurrences.
      
        $ perf report --no-children --stdio -g percent
        ...
          39.93%  swapper  [kernel.vmlinux]  [k] intel_idel
                  |
                  ---intel_idle
                     cpuidle_enter_state
                     cpuidle_enter
                     call_cpuidle
                     cpu_startup_entry
                     |
                     |--28.63%-- start_secondary
                     |
                      --11.30%-- rest_init
      
        $ perf report --no-children --show-total-period --stdio -g period
        ...
          39.93%   13018705  swapper  [kernel.vmlinux]  [k] intel_idel
                  |
                  ---intel_idle
                     cpuidle_enter_state
                     cpuidle_enter
                     call_cpuidle
                     cpu_startup_entry
                     |
                     |--9334403-- start_secondary
                     |
                      --3684302-- rest_init
      
        $ perf report --no-children --show-nr-samples --stdio -g count
        ...
          39.93%     80  swapper  [kernel.vmlinux]  [k] intel_idel
                  |
                  ---intel_idle
                     cpuidle_enter_state
                     cpuidle_enter
                     call_cpuidle
                     cpu_startup_entry
                     |
                     |--57-- start_secondary
                     |
                      --23-- rest_init
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NBrendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1447047946-1691-6-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f2af0086
    • N
      perf callchain: Add count fields to struct callchain_node · 5e47f8ff
      Namhyung Kim 提交于
      It's to track the count of occurrences of the callchains.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Acked-by: NBrendan Gregg <brendan.d.gregg@gmail.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1447047946-1691-5-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5e47f8ff
    • N
      perf callchain: Abstract callchain print function · 5ab250ca
      Namhyung Kim 提交于
      This is a preparation to support for printing other type of callchain
      value like count or period.
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NBrendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1447047946-1691-4-git-send-email-namhyung@kernel.org
      [ renamed new _sprintf_ operation to _scnprintf_ ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5ab250ca
    • N
      perf report: Support folded callchain mode on --stdio · 26e77924
      Namhyung Kim 提交于
      Add new call chain option (-g) 'folded' to print callchains in a line.
      The callchains are separated by semicolons, and preceded by (absolute)
      percent values and a space.
      
      For example, the following 20 lines can be printed in 3 lines with the
      folded output mode:
      
        $ perf report -g flat --no-children | grep -v ^# | head -20
            60.48%  swapper  [kernel.vmlinux]  [k] intel_idle
                    54.60%
                       intel_idle
                       cpuidle_enter_state
                       cpuidle_enter
                       call_cpuidle
                       cpu_startup_entry
                       start_secondary
      
                    5.88%
                       intel_idle
                       cpuidle_enter_state
                       cpuidle_enter
                       call_cpuidle
                       cpu_startup_entry
                       rest_init
                       start_kernel
                       x86_64_start_reservations
                       x86_64_start_kernel
      
        $ perf report -g folded --no-children | grep -v ^# | head -3
            60.48%  swapper  [kernel.vmlinux]  [k] intel_idle
        54.60% intel_idle;cpuidle_enter_state;cpuidle_enter;call_cpuidle;cpu_startup_entry;start_secondary
        5.88% intel_idle;cpuidle_enter_state;cpuidle_enter;call_cpuidle;cpu_startup_entry;rest_init;start_kernel;x86_64_start_reservations;x86_64_start_kernel
      
      This mode is supported only for --stdio now and intended to be used by
      some scripts like in FlameGraphs[1].  Support for other UI might be
      added later.
      
      [1] http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.htmlRequested-and-Tested-by: NBrendan Gregg <brendan.d.gregg@gmail.com>
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1447047946-1691-2-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      26e77924
    • M
      perf machine: Fix machine__findnew_module_map to put dso · 566c69c3
      Masami Hiramatsu 提交于
      Fix machine__findnew_module_map to drop the reference to the dso because
      it is already referenced by both machine__findnew_module_dso() and
      map__new2().
      
      Refcnt debugger shows:
      
        ==== [1] ====
        Unreclaimed dso: 0x1ffd980
        Refcount +1 => 1 at
          ./perf(dso__new+0x1ff) [0x4a62df]
          ./perf(__dsos__addnew+0x29) [0x4a6e19]
          ./perf() [0x4b8b91]
          ./perf(modules__parse+0xfc) [0x4a9d5c]
          ./perf() [0x4b8460]
          ./perf(machine__create_kernel_maps+0x150) [0x4bb550]
          ./perf(machine__new_host+0xfa) [0x4bb75a]
          ./perf(init_probe_symbol_maps+0x93) [0x506623]
          ./perf() [0x455ffa]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f1345a8eaf5]
          ./perf() [0x4220a9]
      
      This map_groups__insert(0x4b8b91) already gets a reference to the new
      dso:
      
        ----
        eu-addr2line -e ./perf -f 0x4b8b91
        map_groups__insert inlined at util/machine.c:586 in
        machine__create_module
        util/map.h:207
        ----
      
      So this dso refcnt will be released when map_groups gets released.
      
        [snip]
        Refcount +1 => 2 at
          ./perf(dso__get+0x34) [0x4a65f4]
          ./perf() [0x4b8b35]
          ./perf(modules__parse+0xfc) [0x4a9d5c]
          ./perf() [0x4b8460]
          ./perf(machine__create_kernel_maps+0x150) [0x4bb550]
          ./perf(machine__new_host+0xfa) [0x4bb75a]
          ./perf(init_probe_symbol_maps+0x93) [0x506623]
          ./perf() [0x455ffa]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f1345a8eaf5]
          ./perf() [0x4220a9]
      
      Here, machine__findnew_module_dso(0x4b8b35) gets the dso (and stores it
      in a local variable):
      
        ----
        # eu-addr2line -e ./perf -f 0x4b8b35
        machine__findnew_module_dso inlined at util/machine.c:578 in
        machine__create_module
        util/machine.c:514
        ----
      
        Refcount +1 => 3 at
          ./perf(dso__get+0x34) [0x4a65f4]
          ./perf(map__new2+0x76) [0x4be1c6]
          ./perf() [0x4b8b4f]
          ./perf(modules__parse+0xfc) [0x4a9d5c]
          ./perf() [0x4b8460]
          ./perf(machine__create_kernel_maps+0x150) [0x4bb550]
          ./perf(machine__new_host+0xfa) [0x4bb75a]
          ./perf(init_probe_symbol_maps+0x93) [0x506623]
          ./perf() [0x455ffa]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f1345a8eaf5]
          ./perf() [0x4220a9]
      
      But also map__new2() gets the dso which will be put when the map is
      released.
      
      So, we have to drop the constructor reference obtained in
      machine__findnew_module_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/20151118064035.30709.58824.stgit@localhost.localdomainSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      566c69c3
    • M
      perf tools: Fix machine__create_kernel_maps to put kernel dso refcount · 1154c957
      Masami Hiramatsu 提交于
      Fix machine__create_kernel_maps() to put kernel dso because the dso has
      been gotten via __machine__create_kernel_maps().
      
      Refcnt debugger shows:
        ==== [0] ====
        Unreclaimed dso: 0x3036ab0
        Refcount +1 => 1 at
          ./perf(dso__new+0x1ff) [0x4a62df]
          ./perf(__dsos__addnew+0x29) [0x4a6e19]
          ./perf(dsos__findnew+0xd1) [0x4a7181]
          ./perf(machine__findnew_kernel+0x27) [0x4a5e17]
          ./perf() [0x4b8cf2]
          ./perf(machine__create_kernel_maps+0x28) [0x4bb428]
          ./perf(machine__new_host+0xfa) [0x4bb74a]
          ./perf(init_probe_symbol_maps+0x93) [0x506613]
          ./perf() [0x455ffa]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7ffa6809eaf5]
          ./perf() [0x4220a9]
        [snip]
        Refcount +1 => 2 at
          ./perf(dsos__findnew+0x7e) [0x4a712e]
          ./perf(machine__findnew_kernel+0x27) [0x4a5e17]
          ./perf() [0x4b8cf2]
          ./perf(machine__create_kernel_maps+0x28) [0x4bb428]
          ./perf(machine__new_host+0xfa) [0x4bb74a]
          ./perf(init_probe_symbol_maps+0x93) [0x506613]
          ./perf() [0x455ffa]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7ffa6809eaf5]
          ./perf() [0x4220a9]
        [snip]
        Refcount -1 => 1 at
          ./perf(dso__put+0x2f) [0x4a664f]
          ./perf(machine__delete+0xfe) [0x4b93ee]
          ./perf(exit_probe_symbol_maps+0x28) [0x5066b8]
          ./perf() [0x45628a]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7ffa6809eaf5]
          ./perf() [0x4220a9]
      
      Actually, dsos__findnew gets the dso before returning it, so the dso
      user (in this case machine__create_kernel_maps) has to put the dso after
      used.
      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/20151118064033.30709.98954.stgit@localhost.localdomainSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1154c957
    • M
      perf tools: Fix __dsos__addnew to put dso after adding it to the list · 82de26ab
      Masami Hiramatsu 提交于
      __dsos__addnew should drop the constructor reference to dso after adding
      it to the list, because __dsos__add() will get a reference that will be
      kept while it is in the list.
      
      This fixes DSO leaks when entries are removed to the list and the refcount
      never gets to zero.
      
      Refcnt debugger shows:
        ==== [0] ====
        Unreclaimed dso: 0x2fccab0
        Refcount +1 => 1 at
          ./perf(dso__new+0x1ff) [0x4a62df]
          ./perf(__dsos__addnew+0x29) [0x4a6e19]
          ./perf(dsos__findnew+0xd1) [0x4a7281]
          ./perf(machine__findnew_kernel+0x27) [0x4a5e17]
          ./perf() [0x4b8df2]
          ./perf(machine__create_kernel_maps+0x28) [0x4bb528]
          ./perf(machine__new_host+0xfa) [0x4bb84a]
          ./perf(init_probe_symbol_maps+0x93) [0x506713]
          ./perf() [0x455ffa]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f46df132af5]
          ./perf() [0x4220a9]
        Refcount +1 => 2 at
          ./perf(__dsos__addnew+0xfb) [0x4a6eeb]
          ./perf(dsos__findnew+0xd1) [0x4a7281]
          ./perf(machine__findnew_kernel+0x27) [0x4a5e17]
          ./perf() [0x4b8df2]
          ./perf(machine__create_kernel_maps+0x28) [0x4bb528]
          ./perf(machine__new_host+0xfa) [0x4bb84a]
          ./perf(init_probe_symbol_maps+0x93) [0x506713]
          ./perf() [0x455ffa]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f46df132af5]
          ./perf() [0x4220a9]
        Refcount +1 => 3 at
          ./perf(dsos__findnew+0x7e) [0x4a722e]
          ./perf(machine__findnew_kernel+0x27) [0x4a5e17]
          ./perf() [0x4b8df2]
          ./perf(machine__create_kernel_maps+0x28) [0x4bb528]
          ./perf(machine__new_host+0xfa) [0x4bb84a]
          ./perf(init_probe_symbol_maps+0x93) [0x506713]
          ./perf() [0x455ffa]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f46df132af5]
          ./perf() [0x4220a9]
        [snip]
      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/20151118064031.30709.81460.stgit@localhost.localdomainSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      82de26ab
    • M
      perf tools: Fix to put new map after inserting to map_groups in dso__load_sym · 8d5c340d
      Masami Hiramatsu 提交于
      Fix dso__load_sym to put the map object which is already
      insterted to kmaps.
      
      Refcnt debugger shows
        ==== [0] ====
        Unreclaimed map: 0x39113e0
        Refcount +1 => 1 at
          ./perf(map__new2+0xb5) [0x4be155]
          ./perf(dso__load_sym+0xee1) [0x503461]
          ./perf(dso__load_vmlinux+0xbf) [0x4aa6df]
          ./perf(dso__load_vmlinux_path+0x8c) [0x4aa83c]
          ./perf() [0x50528a]
          ./perf(convert_perf_probe_events+0xd79) [0x50ac29]
          ./perf() [0x45600f]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f152368baf5]
          ./perf() [0x4220a9]
        Refcount +1 => 2 at
          ./perf(maps__insert+0x9a) [0x4bfffa]
          ./perf(dso__load_sym+0xf89) [0x503509]
          ./perf(dso__load_vmlinux+0xbf) [0x4aa6df]
          ./perf(dso__load_vmlinux_path+0x8c) [0x4aa83c]
          ./perf() [0x50528a]
          ./perf(convert_perf_probe_events+0xd79) [0x50ac29]
          ./perf() [0x45600f]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f152368baf5]
          ./perf() [0x4220a9]
        Refcount -1 => 1 at
          ./perf(map_groups__exit+0x94) [0x4bed04]
          ./perf(machine__delete+0xb0) [0x4b9300]
          ./perf(exit_probe_symbol_maps+0x28) [0x506608]
          ./perf() [0x45628a]
          ./perf(cmd_probe+0x6c) [0x4566bc]
          ./perf() [0x47abc5]
          ./perf(main+0x610) [0x421f90]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f152368baf5]
          ./perf() [0x4220a9]
      
      This means that the dso__load_sym calls map__new2 and maps_insert, both
      of them bump the map refcount, but map_groups__exit will drop just one
      reference.
      
      Fix it by dropping the refcount after inserting it into kmaps.
      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/20151118064026.30709.50038.stgit@localhost.localdomainSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8d5c340d
    • M
      perf tools: Make perf_exec_path() always return malloc'd string · c4068f51
      Masami Hiramatsu 提交于
      Since system_path() returns malloc'd string if given path is not an
      absolute path, perf_exec_path() sometimes returns a static string and
      sometimes returns a malloc'd string depending on the environment
      variables or command options.
      
      This may cause a memory leak because the caller can not unconditionally
      free the returned string.
      
      This fixes perf_exec_path() and system_path() to always return a
      malloc'd string, so the caller can always free it.
      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/20151119060453.14210.65666.stgit@localhost.localdomainSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c4068f51