1. 16 Feb, 2018 12 commits
    • yuzhoujian's avatar
      perf stat: Add support to print counts for fixed times · db06a269
      yuzhoujian authored
      Introduce a new option to print counts for fixed number of times and
      update 'perf stat' documentation accordingly.
      
      Show below is the output of the new option for perf stat.
      
        $ perf stat -I 1000 --interval-count 2 -e cycles -a
        #           time             counts unit events
                 1.002827089         93,884,870      cycles
                 2.004231506         56,573,446      cycles
      
      We can just print the counts for several times with this newly
      introduced option. The usage of it is a little like 'vmstat', and it
      should be used together with "-I" option.
      
        $ vmstat -n 1 2
        procs ---------memory-------------- --swap- ----io-- -system-- ------cpu---
         r  b swpd   free   buff   cache    si   so  bi   bo  in   cs us sy id wa st
         0  0    0 78270544 547484 51732076  0   0   0   20    1    1  1  0 99  0 0
         0  0    0 78270512 547484 51732080  0   0   0   16  477 1555  0  0 100 0 0
      
      Changes since v3:
      - merge interval_count check and times check to one line.
      - fix the wrong indent in stat.h
      - use stat_config.times instead of 'times' in cmd_stat function.
      
      Changes since v2:
      - none.
      
      Changes since v1:
      - change the name of the new option "times-print" to "interval-count".
      - keep the new option interval specifically.
      Signed-off-by: default avataryuzhoujian <yuzhoujian@didichuxing.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1517217923-8302-2-git-send-email-ufo19890607@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      db06a269
    • Jiri Olsa's avatar
      perf report: Add support to display group output for non group events · ad52b8cb
      Jiri Olsa authored
      Add support to display group output for if non grouped events are
      detected and user forces --group option. Now for non-group events
      recorded like:
      
        $ perf record -e 'cycles,instructions' ls
      
      you can still get group output by using --group option
      in report:
      
        $ perf report --group --stdio
        ...
        #         Overhead  Command  Shared Object     Symbol
        # ................  .......  ................  ......................
        #
            17.67%   0.00%  ls       libc-2.25.so      [.] _IO_do_write@@GLIB
            15.59%  25.94%  ls       ls                [.] calculate_columns
            15.41%  31.35%  ls       libc-2.25.so      [.] __strcoll_l
        ...
      
      Committer note:
      
      We should improve on this by making sure that the first line states that
      this is not a group, but since the user doesn't have to force group view
      when really using grouped events (e.g. '{cycles,instructions}'), the
      user better know what is being done...
      Requested-by: default avatarStephane Eranian <eranian@google.com>
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: default avatarStephane Eranian <eranian@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180209092734.GB20449@kravaSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ad52b8cb
    • Jiri Olsa's avatar
      perf report: Ask for ordered events for --tasks option · 8614ada0
      Jiri Olsa authored
      If we have the time in, keep the events in time order.
      
      Committer notes:
      
      Trying to be more verbose, what actual effect this will have in this particular
      case?
      
      Before and after this patch shows the artifacts:
      
        --- /tmp/before 2018-02-06 15:40:29.536411625 -0300
        +++ /tmp/after  2018-02-06 15:40:51.963403599 -0300
        @@ -5,34 +5,34 @@
               2540     2540     1818 |   gnome-terminal-
               3489     3489     2540 |    bash
              32433    32433     3489 |     perf
        -     32434    32434    32433 |      perf
        +     32434    32434    32433 |      make
              32441    32441    32434 |       make
              32514    32514    32441 |        make
                511      511    32514 |         sh
        -       512      512      511 |          sh
        +       512      512      511 |          install
      <SNIP>
      
      We don't have 'perf' calling 'perf' calling 'make', etc, the second
      'perf' actually is 'make', i.e.  there was reordering of the relevant
      PERF_RECORD_COMM and PERF_RECORD_FORK records.
      
      Ditto for sh/install later on.
      
      Look for FORK and COMM meta events, for those tids:
      
        # perf report -D | egrep 'PERF_RECORD_(FORK|COMM)' | egrep '3243[34]'
        0 14774650990679 0x1a3cd8 [0x38]: PERF_RECORD_FORK(32433:32433):(3489:3489)
        1 14774652080381 0x1d6568 [0x30]: PERF_RECORD_COMM exec: perf:32433/32433
        1 14774742473340 0x1dbb48 [0x38]: PERF_RECORD_FORK(32434:32434):(32433:32433)
        0 14774752005779 0x1a4af8 [0x30]: PERF_RECORD_COMM exec: make:32434/32434
        0 14774753997960 0x1a5578 [0x38]: PERF_RECORD_FORK(32435:32435):(32434:32434)
        0 14774756070782 0x1a5618 [0x38]: PERF_RECORD_FORK(32438:32438):(32434:32434)
        0 14774757772939 0x1a5680 [0x38]: PERF_RECORD_FORK(32440:32440):(32434:32434)
        0 14774758230600 0x1a56e8 [0x38]: PERF_RECORD_FORK(32441:32441):(32434:32434)
        #
      
      First column is the cpu, second is the timestamp.
      
      So they are on different CPUs, thus ring buffers, and when we don't use
      the ordered_events class, we end up mixing that up, use it to take
      advantage of the PERF_RECORD_FINISHED_ROUND meta events to go on
      ordering the events using the PERF_SAMPLE_TIME present in the
      PERF_RECORD_{FORK,COMM,EXIT,SAMPLE,etc} records in the ring buffer.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180206181813.10943-2-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      8614ada0
    • Jiri Olsa's avatar
      perf tools: Fix comment for sort__* compare functions · a7402c94
      Jiri Olsa authored
      In commit 2f15bd8c ("perf tools: Fix "Command" sort_entry's cmp and
      collapse function") we switched from pointer to string comparison.
      
      But failed to remove related comments. Removing them and adding another
      one to warn before pointer comparison in here.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180206181813.10943-18-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a7402c94
    • Jiri Olsa's avatar
      perf tests: Fix dwarf unwind for stripped binaries · fdf7c49c
      Jiri Olsa authored
      When we strip the perf binary, dwarf unwind test stop
      to work. The reason is that strip will remove static
      function symbols, which we need to check for unwind.
      
      This change will keep this test working in cases where
      the global symbols are put into dynamic symbol table,
      which is the case on x86. It still won't work on powerpc.
      
      Making those 5 local functions global, and adding
      'test_dwarf_unwind__' to their names.
      
      Committer testing:
      
      Before:
      
        # perf test dwarf
        58: DWARF unwind                               : Ok
        # strip ~/bin/perf
        # perf test dwarf
        58: DWARF unwind                               : FAILED!
        # perf test -v dwarf
        58: DWARF unwind                               :
        --- start ---
        test child forked, pid 6590
        unwind: thread map already set, dso=/home/acme/bin/perf
        <SNIP>
        unwind: access_mem addr 0x7ffce6c48098 val 48563f, offset 1144
        unwind: test__dwarf_unwind:ip = 0x4a54e5 (0xa54e5)
        got: test__dwarf_unwind 0xa54e5, expecting test__dwarf_unwind
        unwind: '':ip = 0x4a50bb (0xa50bb)
        failed: got unresolved address 0xa50bb
        unwind failed
        test child finished with -1
        ---- end ----
        DWARF unwind: FAILED!
        #
      
      After:
      
        # perf test dwarf
        58: DWARF unwind                               : Ok
        # strip ~/bin/perf
        # perf test dwarf
        58: DWARF unwind                               : Ok
        #
        # perf test -v dwarf
        58: DWARF unwind                               :
        --- start ---
        test child forked, pid 7219
        unwind: thread map already set, dso=/home/acme/bin/perf
        <SNIP>
        unwind: access_mem addr 0x7fff007da2c8 val 48575f, offset 1144
        unwind: test__arch_unwind_sample:ip = 0x589044 (0x189044)
        got: test__arch_unwind_sample 0x189044, expecting test__arch_unwind_sample
        unwind: test_dwarf_unwind__thread:ip = 0x4a52f7 (0xa52f7)
        got: test_dwarf_unwind__thread 0xa52f7, expecting test_dwarf_unwind__thread
        unwind: test_dwarf_unwind__compare:ip = 0x4a5468 (0xa5468)
        got: test_dwarf_unwind__compare 0xa5468, expecting test_dwarf_unwind__compare
        unwind: bsearch:ip = 0x7f6608ae94d8 (0x394d8)
        got: bsearch 0x394d8, expecting bsearch
        unwind: test_dwarf_unwind__krava_3:ip = 0x4a54d1 (0xa54d1)
        got: test_dwarf_unwind__krava_3 0xa54d1, expecting test_dwarf_unwind__krava_3
        unwind: test_dwarf_unwind__krava_2:ip = 0x4a550b (0xa550b)
        got: test_dwarf_unwind__krava_2 0xa550b, expecting test_dwarf_unwind__krava_2
        unwind: test_dwarf_unwind__krava_1:ip = 0x4a554b (0xa554b)
        got: test_dwarf_unwind__krava_1 0xa554b, expecting test_dwarf_unwind__krava_1
        unwind: test__dwarf_unwind:ip = 0x4a5605 (0xa5605)
        got: test__dwarf_unwind 0xa5605, expecting test__dwarf_unwind
        test child finished with 0
        ---- end ----
        DWARF unwind: Ok
        #
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180206181813.10943-17-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fdf7c49c
    • Jiri Olsa's avatar
      tools lib api fs: Add sysfs__read_xll function · d9c5f322
      Jiri Olsa authored
      Adding sysfs__read_xll function to be able to read sysfs files with hex
      numbers in, which do not have 0x prefix.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180206181813.10943-6-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d9c5f322
    • Jiri Olsa's avatar
      tools lib api fs: Add filename__read_xll function · 6baddfc6
      Jiri Olsa authored
      Adding filename__read_xll function to be able to read files with hex
      numbers in, which do not have 0x prefix.
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180206181813.10943-5-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6baddfc6
    • Jiri Olsa's avatar
      perf script: Add --show-round-event to display PERF_RECORD_FINISHED_ROUND · 3233b37a
      Jiri Olsa authored
      Adding --show-round-event to display PERF_RECORD_FINISHED_ROUND events
      like:
      
        # perf script --show-round-events 2>/dev/null
                     yes  8591 [002] 124177.397597:         18         cpu/mem-stores/P: ff...
                     yes  8591 [002] 124177.397615:          1 cpu/mem-loads,ldlat=30/P: ff...
        PERF_RECORD_FINISHED_ROUND
                    perf 10380 [001] 124177.397622:          6 cpu/mem-loads,ldlat=30/P: ff...
        PERF_RECORD_FINISHED_ROUND
                 swapper     0 [000] 124177.400518:         88         cpu/mem-stores/P: ff...
                 swapper     0 [000] 124177.400521:         88         cpu/mem-stores/P: ff...
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20180206181813.10943-4-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3233b37a
    • Jiri Olsa's avatar
      perf record: Put new line after target override warning · c3dec27b
      Jiri Olsa authored
      There's no new-line after target-override warning, now:
      
        $ perf record -a --per-thread
        Warning:
        SYSTEM/CPU switch overriding PER-THREAD^C[ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.705 MB perf.data (2939 samples) ]
      
      with patch:
      
        $ perf record -a --per-thread
        Warning:
        SYSTEM/CPU switch overriding PER-THREAD
        ^C[ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.705 MB perf.data (2939 samples) ]
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Fixes: 16ad2ffb ("perf tools: Introduce perf_target__strerror()")
      Link: http://lkml.kernel.org/r/20180206181813.10943-3-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c3dec27b
    • Jessica Yu's avatar
      kprobes: Propagate error from disarm_kprobe_ftrace() · 297f9233
      Jessica Yu authored
      Improve error handling when disarming ftrace-based kprobes. Like with
      arm_kprobe_ftrace(), propagate any errors from disarm_kprobe_ftrace() so
      that we do not disable/unregister kprobes that are still armed. In other
      words, unregister_kprobe() and disable_kprobe() should not report success
      if the kprobe could not be disarmed.
      
      disarm_all_kprobes() keeps its current behavior and attempts to
      disarm all kprobes. It returns the last encountered error and gives a
      warning if not all probes could be disarmed.
      
      This patch is based on Petr Mladek's original patchset (patches 2 and 3)
      back in 2015, which improved kprobes error handling, found here:
      
         https://lkml.org/lkml/2015/2/26/452
      
      However, further work on this had been paused since then and the patches
      were not upstreamed.
      Based-on-patches-by: default avatarPetr Mladek <pmladek@suse.com>
      Signed-off-by: default avatarJessica Yu <jeyu@kernel.org>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: David S . Miller <davem@davemloft.net>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Joe Lawrence <joe.lawrence@redhat.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Miroslav Benes <mbenes@suse.cz>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: live-patching@vger.kernel.org
      Link: http://lkml.kernel.org/r/20180109235124.30886-3-jeyu@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      297f9233
    • Jessica Yu's avatar
      kprobes: Propagate error from arm_kprobe_ftrace() · 12310e34
      Jessica Yu authored
      Improve error handling when arming ftrace-based kprobes. Specifically, if
      we fail to arm a ftrace-based kprobe, register_kprobe()/enable_kprobe()
      should report an error instead of success. Previously, this has lead to
      confusing situations where register_kprobe() would return 0 indicating
      success, but the kprobe would not be functional if ftrace registration
      during the kprobe arming process had failed. We should therefore take any
      errors returned by ftrace into account and propagate this error so that we
      do not register/enable kprobes that cannot be armed. This can happen if,
      for example, register_ftrace_function() finds an IPMODIFY conflict (since
      kprobe_ftrace_ops has this flag set) and returns an error. Such a conflict
      is possible since livepatches also set the IPMODIFY flag for their ftrace_ops.
      
      arm_all_kprobes() keeps its current behavior and attempts to arm all
      kprobes. It returns the last encountered error and gives a warning if
      not all probes could be armed.
      
      This patch is based on Petr Mladek's original patchset (patches 2 and 3)
      back in 2015, which improved kprobes error handling, found here:
      
         https://lkml.org/lkml/2015/2/26/452
      
      However, further work on this had been paused since then and the patches
      were not upstreamed.
      Based-on-patches-by: default avatarPetr Mladek <pmladek@suse.com>
      Signed-off-by: default avatarJessica Yu <jeyu@kernel.org>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: David S . Miller <davem@davemloft.net>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Joe Lawrence <joe.lawrence@redhat.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Miroslav Benes <mbenes@suse.cz>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: live-patching@vger.kernel.org
      Link: http://lkml.kernel.org/r/20180109235124.30886-2-jeyu@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      12310e34
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-4.17-20180215' of... · 3f9e6463
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-4.17-20180215' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/core fixes from Arnaldo Carvalho de Melo:
      
      - perf_mmap overwrite mode fixes/overhaul, prep work to get 'perf top'
        using it, making it bearable to use it in large core count systems
        such as Knights Landing/Mill Intel systems (Kan Liang)
      
      - s/390 now uses syscall.tbl, just like x86-64 to generate the syscall
        table id -> string tables used by 'perf trace' (Hendrik Brueckner)
      
      - Use strtoull() instead of home grown function (Andy Shevchenko)
      
      - Synchronize kernel ABI headers, v4.16-rc1 (Ingo Molnar)
      
      - Document missing 'perf data --force' option (Sangwon Hong)
      
      - Add perf vendor JSON metrics for ARM Cortex-A53 Processor (William Cohen)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      3f9e6463
  2. 15 Feb, 2018 28 commits