1. 28 11月, 2015 6 次提交
    • N
      perf hists browser: Update nr entries regardless of min percent · 03905048
      Namhyung Kim 提交于
      When perf report on TUI was called with -S symbol filter, it should
      update nr entries even if min_pcnt is 0.  IIRC the reason was to update
      nr entries after applying minimum percent threshold.  But if symbol
      filter was given on command line (with -S option), it should use
      hists->nr_non_filtered_entries instead of hists->nr_entries.
      
      So this patch fixes a bug of navigating hists browser that the cursor
      goes beyond the number of entries when -S (or similar) option is used.
      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-3-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      03905048
    • 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
    • N
      perf report: Show error message when processing sample fails · 25b1606b
      Namhyung Kim 提交于
      Currently when perf fails to process samples for some reason, it doesn't
      show any message about the failure.  This is very inconvenient for users
      especially on TUI as screen is reset after the failure.
      Reported-by: NIngo Molnar <mingo@kernel.org>
      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/1448645559-31167-1-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      25b1606b
    • 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
    • J
      perf test: 'unwind' test should create kernel maps · 9bdcede5
      Jiri Olsa 提交于
      The 'perf test unwind' is failing because it forgot to create the kernel
      maps, fix it.
      
      After the patch:
      
        # perf test unwind
        40: Test dwarf unwind         : Ok
      Reported-and-Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NJiri Olsa <jolsa@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/20151127082121.GA24503@krava.brq.redhat.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9bdcede5
  2. 27 11月, 2015 15 次提交
    • 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
    • I
      Merge tag 'perf-core-for-mingo' of... · 3f3b1a46
      Ingo Molnar 提交于
      Merge tag 'perf-core-for-mingo' 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 'vmlinux.debug' to the vmlinux search path (Ekaterina Tumanova)
      
        - Do not show sample_(type|period) in the perf_event_attr dump when using
          -v with 'perf stat' (Jiri Olsa)
      
        - Display the WEIGHT sample bit, when set, in 'perf evlist -v' (Jiri Olsa)
      
        - Honour --hide-unresolved in 'report', will honour it as well in 'top'
          when --hide-unresolved gets supported in that tool (Namhyung Kim)
      
        - Fix freeze wit h--call-graph 'flat/folded' due to not properly
          reinitializing the callchain rb_tree (Namhyumg Kim)
      
        - Set dso->long_name when a module name is passed as a parameter
          to tools like 'perf probe' but the 'struct dso' associated to that module
          still doesn't have the full path for the module, just the '[name]' one
          obtained from /proc/modules (Wang Nan)
      
        - Fix anon_hugepage mmaps detection using scanf on /proc/PID/smaps (Yannick Brosseau)
      
      Infrastructure changes:
      
        - Add helper function for updating bpf maps elements (He Kuang)
      
        - Fix traceevents plugins build race (Jiri Olsa)
      
        - Add the $OUTPUT path prefix with 'fixdep' (Jiri Olsa)
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      3f3b1a46
    • H
      bpf tools: Add helper function for updating bpf maps elements · 43798bf3
      He Kuang 提交于
      Add bpf_map_update_elem() helper function which calls the sys_bpf
      syscall to update elements in bpf maps. Upcoming patches will use it to
      adjust data in map through the perf command line.
      Signed-off-by: NHe Kuang <hekuang@huawei.com>
      Cc: Alexei Starovoitov <ast@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/1448372181-151723-4-git-send-email-wangnan0@huawei.comSigned-off-by: NWang Nan <wangnan0@huawei.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      43798bf3
    • 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
    • J
      perf stat: Clear sample_(type|period) for counting · 6acd8e92
      Jiri Olsa 提交于
      Clear sample_(type|period) for counting, as it only confuses debug
      output with unwanted sampling details:
      
      Before:
      
        $ sudo perf stat -e 'raw_syscalls:sys_enter' -vv ls
        ------------------------------------------------------------
        perf_event_attr:
          type                             2
          size                             112
          config                           0x11
          { sample_period, sample_freq }   1
          sample_type                      TIME|CPU|PERIOD|RAW
          read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
          disabled                         1
          inherit                          1
          enable_on_exec                   1
          exclude_guest                    1
        ...
      
      After:
        $ sudo perf stat -e 'raw_syscalls:sys_enter' -vv ls
        ------------------------------------------------------------
        perf_event_attr:
          type                             2
          size                             112
          config                           0x11
          read_format                      TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
          disabled                         1
          inherit                          1
          enable_on_exec                   1
          exclude_guest                    1
        ...
      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-1-git-send-email-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6acd8e92
    • 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
    • J
      tools build: Use fixdep with OUTPUT path prefix · 5e50426d
      Jiri Olsa 提交于
      Adding OUTPUT path prefix for fixdep target so we use it properly in out
      of tree builds.
      
      If the fixdep already existed in the tree, the out of tree build would
      see it already exist and did not build the out of tree version, as
      reported by Arnaldo:
      
        [acme@zoo linux]$ make O=/tmp/build/perf -C tools/perf
        make: Entering directory '/home/git/linux/tools/perf'
          BUILD:   Doing 'make -j4' parallel build
        make[2]: Nothing to be done for 'fixdep'.
        make: Leaving directory '/home/git/linux/tools/perf'
      Reported-and-Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/20151126185055.GC19410@krava.brq.redhat.com
      [ Fixed conflict with 5725dd8f ("tools build: Clean CFLAGS and LDFLAGS for fixdep") ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5e50426d
    • J
      perf script: Pass perf_script into process_event · 809e9423
      Jiri Olsa 提交于
      Passing perf_script struct into process_event function, so we could
      process configuration data for event printing.
      
      It will be used in following patch to get event name string width.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      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/20151126175521.GA18979@krava.brq.redhat.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      809e9423
    • 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
    • J
      perf build: Fix traceevent plugins build race · 67befc65
      Jiri Olsa 提交于
      Ingo reported following build failure:
      
        $ make clean install
        ...
          CC       plugin_kmem.o
        fixdep: error opening depfile: ./.plugin_hrtimer.o.d: No such file or directory
        /home/mingo/tip/tools/build/Makefile.build:77: recipe for target
        'plugin_hrtimer.o' failed
        make[3]: *** [plugin_hrtimer.o] Error 2
        Makefile:189: recipe for target 'plugin_hrtimer-in.o' failed
        make[2]: *** [plugin_hrtimer-in.o] Error 2
        Makefile.perf:414: recipe for target 'libtraceevent_plugins' failed
        make[1]: *** [libtraceevent_plugins] Error 2
        make[1]: *** Waiting for unfinished jobs....
      
      Currently we have the install-traceevent-plugins target being dependent
      on $(LIBTRACEEVENT), which will actualy not build any plugin. So the
      install-traceevent-plugins target itself will try to build plugins,
      but..
      
      Plugins built is also triggered by perf build itself via
      libtraceevent_plugins target.
      
      This might cause a race having one make thread removing temp files from
      another and result in above error. Fixing this by having proper plugins
      build dependency before installing plugins.
      Reported-and-Tested-by: N: Ingo Molnar <mingo@kernel.org>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      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/1448546044-28973-3-git-send-email-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      67befc65
    • J
      perf script: Remove default_scripting_ops · 2aaecfc5
      Jiri Olsa 提交于
      The default script handler (the one that displays samples on screen) is
      implemented scripting_ops instance with process_event callback.
      
      This way we can't pass any script config into display function, because
      we don't want perl or python handlers to be depended on perf script
      internals.
      
      Removing the default_scripting_ops and calling process event function
      directly. This way it's possible to pass perf_script struct and process
      configuration data in following commit.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NDavid Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1448546125-29245-1-git-send-email-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2aaecfc5
    • 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
  3. 26 11月, 2015 4 次提交
    • I
      Merge tag 'perf-core-for-mingo-2' of... · a95a49fa
      Ingo Molnar 提交于
      Merge tag 'perf-core-for-mingo-2' 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:
      
        - Fix to free temporal Dwarf_Frame correctly in 'perf probe', fixing a
          regression introduced in perf/core that prevented, at least, adding
          an uprobe collecting function parameter values (Masami Hiramatsu)
      
        - Fix output of %llu for 64 bit values read on 32 bit machines in
          libtraceevent (Steven Rostedt)
      
      Developer visible:
      
        - Clean CFLAGS and LDFLAGS for fixdep in tools/build (Wang Nan)
      
        - Don't do a feature check when cleaning tools/lib/bpf (Wang Nan)
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      a95a49fa
    • W
      tools lib bpf: Don't do a feature check when cleaning · d8ad6a15
      Wang Nan 提交于
      Before this patch libbpf always do feature check even when cleaning.
      
      For example:
      
        $ cd kernel/tools/lib/bpf
        $ make
      
        Auto-detecting system features:
        ...                        libelf: [ on  ]
        ...                           bpf: [ on  ]
      
          CC       libbpf.o
          CC       bpf.o
          LD       libbpf-in.o
          LINK     libbpf.a
          LINK     libbpf.so
        $ make clean
          CLEAN    libbpf
          CLEAN    core-gen
        $ make clean
      
        Auto-detecting system features:
        ...                        libelf: [ on  ]
        ...                           bpf: [ on  ]
      
          CLEAN    libbpf
          CLEAN    core-gen
        $
      
      Although the first 'make clean' doesn't show feature check result, it
      still does the check. No output because check result is similar to
      FEATURE-DUMP.libbpf.
      
      This patch uses same method as perf to turn off feature checking when
      'make clean'.
      Reported-and-Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1448372181-151723-3-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d8ad6a15
    • W
      tools build: Clean CFLAGS and LDFLAGS for fixdep · 5725dd8f
      Wang Nan 提交于
      Sometimes passing variables to tools/build is dangerous. For example, on
      my platform there is a gcc problem (gcc 4.8.1):
      
      It passes the stackprotector-all feature check:
      
        $ gcc -fstack-protector-all -c ./test.c
        $ echo $?
        0
      
      But requires LDFLAGS support if separate compiling and linking:
        $ gcc -fstack-protector-all -c ./test.c
        $ gcc ./test.o
        ./test.o: In function `main':
        test.c:(.text+0xb): undefined reference to `__stack_chk_guard'
        test.c:(.text+0x21): undefined reference to `__stack_chk_guard'
        collect2: error: ld returned 1 exit status
        $ gcc -fstack-protector-all ./test.o
        $ echo $?
        0
        $ gcc ./test.o -lssp
        $ echo $?
        0
        $
      
      In this environment building perf throws an error:
      
        $ make
          BUILD:   Doing 'make -j24' parallel build
        config/Makefile:344: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR
        config/Makefile:403: No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev
        config/Makefile:418: slang not found, disables TUI support. Please install slang-devel or libslang-dev
        config/Makefile:432: GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev
        config/Makefile:564: No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling
        config/Makefile:606: No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev
          CC       fixdep.o
          LD       fixdep-in.o
          LINK     fixdep
        fixdep-in.o: In function `parse_dep_file':
        /kernel/tools/build/fixdep.c:47: undefined reference to `__stack_chk_guard'
        /kernel/tools/build/fixdep.c:117: undefined reference to `__stack_chk_guard'
        fixdep-in.o: In function `main':
        /kernel-hydrogen/tools/build/fixdep.c:156: undefined reference to `__stack_chk_guard'
        /kernel/tools/build/fixdep.c:168: undefined reference to `__stack_chk_guard'
        collect2: error: ld returned 1 exit status
        make[2]: *** [fixdep] Error 1
        make[1]: *** [fixdep] Error 2
        make: *** [all] Error 2
      
      This is because the CFLAGS used in building perf pollutes the CFLAGS
      used for fixdep, passing -fstack-protector-all to buiold fixdep which is
      obviously not required. Since fixdep is a small host side tool, we
      should keep its CFLAGS/LDFLAGS simple and clean.
      
      This patch clears the CFLAGS and LDFLAGS passed when building fixdep, so
      such gcc problem won't block the perf build process.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1448372181-151723-2-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5725dd8f
    • M
      perf probe: Fix to free temporal Dwarf_Frame correctly · 4d3b1626
      Masami Hiramatsu 提交于
      The commit 05c8d802 ("perf probe: Fix to free temporal Dwarf_Frame")
      tried to fix the memory leak of Dwarf_Frame, but it released the frame
      at wrong point. Since the dwarf_frame_cfa(frame, &pf->fb_ops, &nops) can
      return an address inside the frame data structure to pf->fb_ops, we can
      not release the frame before using pf->fb_ops.
      
      This reverts the commit and releases the frame afterwards (right before
      returning from call_probe_finder) correctly.
      Reported-and-Tested-by: NArnaldo Carvalho de Melo <acme@kernel.org>
      Reported-by: NMichael Petlan <mpetlan@redhat.com>
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 05c8d802 ("perf probe: Fix to free temporal Dwarf_Frame")
      LPU-Reference: 20151125103432.1473.31009.stgit@localhost.localdomain
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4d3b1626
  4. 24 11月, 2015 9 次提交
  5. 23 11月, 2015 6 次提交
    • A
      perf/x86: Handle multiple umask bits for BDW CYCLE_ACTIVITY.* · b7883a1c
      Andi Kleen 提交于
      The earlier constraint fix for Broadwell CYCLE_ACTIVITY.*
      forced umask 8 to counter 2. For this it used UEVENT,
      to match the complete umask.
      
      The event list for Broadwell has an additional
      STALLS_L1D_PENDIND event that uses umask 8, but also
      sets other bits in the umask.  The earlier strict umask match
      didn't handle this case.
      
      Add a new UBIT_EVENT constraint macro that only matches
      the specified bits in the umask. Then use that macro
      to handle CYCLE_ACTIVITY.* on Broadwell.
      
      The documented event also uses cmask, but there's no
      need to let the event scheduler know about the cmask,
      as the scheduling restriction is only tied to the umask.
      Reported-by: NGrant Ayers <ayers@cs.stanford.edu>
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: http://lkml.kernel.org/r/1447719667-9998-1-git-send-email-andi@firstfloor.org
      [ Filled in the missing email address of Grant Ayers - hopefully I got the right one. ]
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      b7883a1c
    • T
      perf, x86: Stop Intel PT before kdump starts · da06a43d
      Takao Indoh 提交于
      This patch stops Intel PT logging and saves its registers in memory
      before kdump is started. This feature is needed to prevent Intel PT from
      overwriting its log buffer after panic, and saved registers are needed to
      find the last position where Intel PT wrote data.
      
      After the crash dump is captured by kdump, users can retrieve the log buffer
      from the vmcore and use it to investigate bad kernel behavior.
      Signed-off-by: NTakao Indoh <indou.takao@jp.fujitsu.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin<alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: H.Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Link: http://lkml.kernel.org/r/1446614553-6072-3-git-send-email-indou.takao@jp.fujitsu.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      da06a43d
    • T
      perf/x86/intel/pt: Add interface to stop Intel PT logging · 24cc12b1
      Takao Indoh 提交于
      This patch add a function for external components to stop Intel PT.
      Basically this function is used when kernel panic occurs. When it is
      called, the intel_pt driver disables Intel PT and saves its registers
      using pt_event_stop(), which is also used by pmu.stop handler.
      
      This function stops Intel PT on the CPU where it is working, therefore
      users of it need to call it for each CPU to stop all logging.
      Signed-off-by: NTakao Indoh <indou.takao@jp.fujitsu.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin<alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: H.Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Link: http://lkml.kernel.org/r/1446614553-6072-2-git-send-email-indou.takao@jp.fujitsu.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      24cc12b1
    • A
      perf/x86: Add option to disable reading branch flags/cycles · b16a5b52
      Andi Kleen 提交于
      With LBRv5 reading the extra LBR flags like mispredict, TSX, cycles is
      not free anymore, as it has moved to a separate MSR.
      
      For callstack mode we don't need any of this information; so we can
      avoid the unnecessary MSR read. Add flags to the perf interface where
      perf record can request not collecting this information.
      
      Add branch_sample_type flags for CYCLES and FLAGS. It's a bit unusual
      for branch_sample_types to be negative (disable), not positive (enable),
      but since the legacy ABI reported the flags we need some form of
      explicit disabling to avoid breaking the ABI.
      
      After we have the flags the x86 perf code can keep track if any users
      need the flags. If noone needs it the information is not collected.
      
      This cuts down the cost of LBR callstack on Skylake significantly.
      Profiling a kernel build with LBR call stack the average run time of
      the PMI handler drops by 43%.
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: acme@kernel.org
      Cc: jolsa@kernel.org
      Link: http://lkml.kernel.org/r/1445366797-30894-2-git-send-email-andi@firstfloor.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      b16a5b52
    • A
      perf/x86: Optimize stack walk user accesses · 75925e1a
      Andi Kleen 提交于
      Change the perf user stack walking to use the new
      __copy_from_user_nmi(), and split each access into word sized transfer
      sizes. This allows to inline the complete access and optimize it all
      into a single load.
      
      The main advantage is that this avoids the overhead of double page
      faults.  When normal copy_from_user() fails it reexecutes the copy to
      compute an accurate number of non copied bytes. This leads to
      executing the expensive page fault twice.
      
      While walking stacks having a fault at some point is relatively common
      (typically when some part of the program isn't compiled with frame
      pointers), so this is a large overhead.
      
      With the optimized copies we avoid this problem because they only do
      all accesses once. And of course they're much faster too when the
      access does not fault because they're just single instructions instead
      of complex function calls.
      
      While profiling a kernel build with -g, the patch brings down the
      average time of the PMI handler from 966ns to 552ns (-43%).
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: http://lkml.kernel.org/r/1445551641-13379-2-git-send-email-andi@firstfloor.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      75925e1a
    • A
      x86: Add an inlined __copy_from_user_nmi() variant · 10013ebb
      Andi Kleen 提交于
      Add a inlined __ variant of copy_from_user_nmi. The inlined variant allows
      the user to:
      
       - batch the access_ok() check for multiple accesses
      
       - avoid having a pagefault_disable/enable() on every access if the
         caller already ensures disabled page faults due to its context.
      
       - get all the optimizations in copy_*_user() for small constant sized
         transfers
      
      It is just a define to __copy_from_user_inatomic().
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1445551641-13379-1-git-send-email-andi@firstfloor.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      10013ebb