1. 11 12月, 2015 5 次提交
  2. 10 12月, 2015 11 次提交
  3. 08 12月, 2015 14 次提交
  4. 07 12月, 2015 5 次提交
    • W
      perf hists browser: Fix segfault if use symbol filter in cmdline · 4938cf0c
      Wang Nan 提交于
      If feed perf a symbol filter in cmdline and the result is empty,
      pressing 'Enter' in the hist browser causes crash:
      
       # ./perf report perf.data   <-- Common mistake for beginners
      
      Then press 'Enter':
      
       perf: Segmentation fault
       -------- backtrace --------
       /home/wangnan/perf[0x53e578]
       /lib64/libc.so.6(+0x3545f)[0x7f76bafe045f]
       /home/wangnan/perf[0x539dd4]
       /home/wangnan/perf(perf_evlist__tui_browse_hists+0x96)[0x53d216]
       /home/wangnan/perf(cmd_report+0x1b9f)[0x442c7f]
       /home/wangnan/perf[0x47efa2]
       /home/wangnan/perf(main+0x5f5)[0x432fa5]
       /lib64/libc.so.6(__libc_start_main+0xf4)[0x7f76bafccbd4]
       /home/wangnan/perf[0x4330d4]
      
      This is because 'perf.data' is interpreted as a symbol filter, and the
      result is empty, so selection is empty. However,
      hist_browser__toggle_fold() forgets to check it.
      
      This patch simply return false when selection is NULL.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1449455746-41952-2-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4938cf0c
    • W
      perf hists browser: Reset selection when refresh · 979d2cac
      Wang Nan 提交于
      With the following steps:
      
       Step 1: perf report
      
       Step 2: Use UP/DOWN to select an entry, don't press 'ENTER'
      
       Step 3: Use '/' to filter symbols, use a filter which returns
               empty result
      
       Step 4: Press 'ENTER'
      
      We see that, even if we have filtered all the symbols (and the main
      interface is empty), pressing 'ENTER' still selects one symbol. This
      behavior surprises the user.
      
      This patch resets browser->{he_,}selection in hist_browser__refresh()
      and lets it choose default selection. In this case
      browser->{he_,}selection keeps NULL so user won't see annotation item in
      menu.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1449455746-41952-4-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      979d2cac
    • W
      perf hists browser: Add NULL pointer check to prevent crash · 837eeb75
      Wang Nan 提交于
      Before this patch we can trigger a segfault by following steps:
      
       Step 0: Use 'perf record' to generate a perf.data without callchain
      
       Step 1: perf report
      
       Step 2: Use UP/DOWN to select an entry, don't press 'ENTER'
      
       Step 3: Use '/' to filter symbols, use a filter which returns
               empty result
      
       Step 4: Press 'ENTER' (notice here that the old selection is still
      		        there. This is another problem)
      
       Step 5: Press 'ENTER' to annotate that symbol
      
       Step 6: Press 'LEFT' to go out.
      
       Result: segfault:
      
       perf: Segmentation fault
       -------- backtrace --------
       /home/wangnan/perf[0x53e568]
       /lib64/libc.so.6(+0x3545f)[0x7fba75d3245f]
       /home/wangnan/perf[0x537516]
       /home/wangnan/perf[0x533fef]
       /home/wangnan/perf[0x53b347]
       /home/wangnan/perf(perf_evlist__tui_browse_hists+0x96)[0x53d206]
       /home/wangnan/perf(cmd_report+0x1b9f)[0x442c7f]
       /home/wangnan/perf[0x47efa2]
       /home/wangnan/perf(main+0x5f5)[0x432fa5]
       /lib64/libc.so.6(__libc_start_main+0xf4)[0x7fba75d1ebd4]
       /home/wangnan/perf[0x4330d4]
      
      This is because in this case 'nd' could be NULL in
      ui_browser__hists_seek(), but that function never checks it.
      
      This patch adds checker for potential NULL pointer in that function.
      After this patch the above steps won't segfault.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1449455746-41952-3-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      837eeb75
    • M
      perf buildid-list: Fix return value of perf buildid-list -k · c8319c9d
      Michael Petlan 提交于
      The buildid string length is returned by perf buildid-list -k command.
      Since a non-zero return value means an error, perf buildid-list -k cmd
      should return 0 when successful instead.
      
      Before:
      
      	# perf buildid-list -k
      	39356d74e96e02346fe0ec1f3f162b6c522bac62
      	# echo $?
      	41
      
      After:
      
      	# perf buildid-list -k
      	39356d74e96e02346fe0ec1f3f162b6c522bac62
      	# echo $?
      	0
      Signed-off-by: NMichael Petlan <mpetlan@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Fixes: 0b5a7935 ("perf buildid: Introduce sysfs/filename__sprintf_build_id")
      LPU-Reference: 1449080871.24573.145.camel@redhat.com
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c8319c9d
    • 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
  5. 28 11月, 2015 5 次提交
    • 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 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