1. 12 1月, 2018 1 次提交
  2. 27 12月, 2017 1 次提交
  3. 06 12月, 2017 6 次提交
    • W
      perf tools: Rename 'backward' to 'overwrite' in evlist, mmap and record · 0b72d69a
      Wang Nan 提交于
      Remove the backward/forward concept to make it uniform with user
      interface (the '--overwrite' option).
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Mengting Zhang <zhangmengting@huawei.com>
      Link: http://lkml.kernel.org/r/20171204165107.95327-4-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0b72d69a
    • W
      perf mmap: Fix perf backward recording · 71f566a3
      Wang Nan 提交于
      'perf record' backward recording doesn't work as we expected: it never
      overwrites when ring buffer gets full.
      
      Test:
      
      Run a busy python printing task background like this:
      
       while True:
           print 123
      
      send SIGUSR2 to perf to capture snapshot, then:
      
       # ./perf record --overwrite -e raw_syscalls:sys_enter -e raw_syscalls:sys_exit --exclude-perf -a --switch-output
       [ perf record: dump data: Woken up 1 times ]
       [ perf record: Dump perf.data.2017110101520743 ]
       [ perf record: dump data: Woken up 1 times ]
       [ perf record: Dump perf.data.2017110101521251 ]
       [ perf record: dump data: Woken up 1 times ]
       [ perf record: Dump perf.data.2017110101521692 ]
       ^C[ perf record: Woken up 1 times to write data ]
       [ perf record: Dump perf.data.2017110101521936 ]
       [ perf record: Captured and wrote 0.826 MB perf.data.<timestamp> ]
      
       # ./perf script -i ./perf.data.2017110101520743 | head -n3
                   perf  2717 [000] 12449.310785: raw_syscalls:sys_enter: NR 16 (5, 2400, 0, 59, 100, 0)
                   perf  2717 [000] 12449.310790: raw_syscalls:sys_enter: NR 7 (4112340, 2, ffffffff, 3df, 100, 0)
                 python  2545 [000] 12449.310800:  raw_syscalls:sys_exit: NR 1 = 4
       # ./perf script -i ./perf.data.2017110101521251 | head -n3
                   perf  2717 [000] 12449.310785: raw_syscalls:sys_enter: NR 16 (5, 2400, 0, 59, 100, 0)
                   perf  2717 [000] 12449.310790: raw_syscalls:sys_enter: NR 7 (4112340, 2, ffffffff, 3df, 100, 0)
                 python  2545 [000] 12449.310800:  raw_syscalls:sys_exit: NR 1 = 4
       # ./perf script -i ./perf.data.2017110101521692 | head -n3
                   perf  2717 [000] 12449.310785: raw_syscalls:sys_enter: NR 16 (5, 2400, 0, 59, 100, 0)
                   perf  2717 [000] 12449.310790: raw_syscalls:sys_enter: NR 7 (4112340, 2, ffffffff, 3df, 100, 0)
                 python  2545 [000] 12449.310800:  raw_syscalls:sys_exit: NR 1 = 4
      
      Timestamps never change, but my background task is a dead loop, can
      easily overwhelm the ring buffer.
      
      This patch fixes it by forcing unsetting PROT_WRITE for a backward ring
      buffer, so all backward ring buffers become overwrite ring buffers.
      
      Test result:
      
       # ./perf record --overwrite -e raw_syscalls:sys_enter -e raw_syscalls:sys_exit --exclude-perf -a --switch-output
       [ perf record: dump data: Woken up 1 times ]
       [ perf record: Dump perf.data.2017110101285323 ]
       [ perf record: dump data: Woken up 1 times ]
       [ perf record: Dump perf.data.2017110101290053 ]
       [ perf record: dump data: Woken up 1 times ]
       [ perf record: Dump perf.data.2017110101290446 ]
       ^C[ perf record: Woken up 1 times to write data ]
       [ perf record: Dump perf.data.2017110101290837 ]
       [ perf record: Captured and wrote 0.826 MB perf.data.<timestamp> ]
       # ./perf script -i ./perf.data.2017110101285323 | head -n3
                 python  2545 [000] 11064.268083:  raw_syscalls:sys_exit: NR 1 = 4
                 python  2545 [000] 11064.268084: raw_syscalls:sys_enter: NR 1 (1, 12cc330, 4, 7fc237280370, 7fc2373d0700, 2c7b0)
                 python  2545 [000] 11064.268086:  raw_syscalls:sys_exit: NR 1 = 4
       # ./perf script -i ./perf.data.2017110101290 | head -n3
       failed to open ./perf.data.2017110101290: No such file or directory
       # ./perf script -i ./perf.data.2017110101290053 | head -n3
                 python  2545 [000] 11071.564062: raw_syscalls:sys_enter: NR 1 (1, 12cc330, 4, 7fc237280370, 7fc2373d0700, 2c7b0)
                 python  2545 [000] 11071.564064:  raw_syscalls:sys_exit: NR 1 = 4
                 python  2545 [000] 11071.564066: raw_syscalls:sys_enter: NR 1 (1, 12cc330, 4, 7fc237280370, 7fc2373d0700, 2c7b0)
       # ./perf script -i ./perf.data.2017110101290 | head -n3
       perf.data.2017110101290053  perf.data.2017110101290446  perf.data.2017110101290837
       # ./perf script -i ./perf.data.2017110101290446 | head -n3
                   sshd  1321 [000] 11075.499473:  raw_syscalls:sys_exit: NR 14 = 0
                   sshd  1321 [000] 11075.499474: raw_syscalls:sys_enter: NR 14 (2, 7ffe98899490, 0, 8, 0, 3000)
                   sshd  1321 [000] 11075.499474:  raw_syscalls:sys_exit: NR 14 = 0
       # ./perf script -i ./perf.data.2017110101290837 | head -n3
                 python  2545 [000] 11079.280844:  raw_syscalls:sys_exit: NR 1 = 4
                 python  2545 [000] 11079.280847: raw_syscalls:sys_enter: NR 1 (1, 12cc330, 4, 7fc237280370, 7fc2373d0700, 2c7b0)
                 python  2545 [000] 11079.280850:  raw_syscalls:sys_exit: NR 1 = 4
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Mengting Zhang <zhangmengting@huawei.com>
      Link: http://lkml.kernel.org/r/20171204165107.95327-2-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      71f566a3
    • W
      perf mmap: Remove overwrite and check_messup from mmap read · 8eb7a1fe
      Wang Nan 提交于
      All perf_mmap__read_forward() read from read-write ring buffer, so no
      need check_messup. Reading from backward ring buffer doesn't require
      check_messup because it never mess up. Cleanup arguments lists.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Link: http://lkml.kernel.org/r/20171203020044.81680-6-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8eb7a1fe
    • W
      perf evlist: Remove evlist->overwrite · 144b9a4f
      Wang Nan 提交于
      evlist->overwrite is set to false in all users. It can be removed.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Link: http://lkml.kernel.org/r/20171203020044.81680-4-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      144b9a4f
    • W
      perf evlist: Remove 'overwrite' parameter from perf_evlist__mmap_ex · 7a276ff6
      Wang Nan 提交于
      All users of perf_evlist__mmap_ex set !overwrite. Remove it from its
      arguments list.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Link: http://lkml.kernel.org/r/20171203020044.81680-3-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7a276ff6
    • W
      perf evlist: Remove 'overwrite' parameter from perf_evlist__mmap · f74b9d3a
      Wang Nan 提交于
      Now all perf_evlist__mmap's users doesn't set 'overwrite'. Remove it
      from arguments list.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Link: http://lkml.kernel.org/r/20171203020044.81680-2-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f74b9d3a
  4. 29 11月, 2017 2 次提交
    • A
      perf evlist: Add helper to check if attr.exclude_kernel is set in all evsels · 5b0d1cb4
      Arnaldo Carvalho de Melo 提交于
      The warning about kptr_restrict needs to be emitted only when it is set
      and we ask for kernel space samples, so add a helper to help with that.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-fh7drty6yljei9gxxzer6eup@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5b0d1cb4
    • A
      perf evlist: Set the correct idx when adding dummy events · 555b4ec4
      Arnaldo Carvalho de Melo 提交于
      The evsel->idx field is used mainly to access the right bucket in
      per-event arrays such as the annotation ones, but also to set
      evsel->tracking, that in turn will decide what of the events will ask
      for PERF_RECORD_{MMAP,COMM,EXEC} to be generated, i.e. which
      perf_event_attr will have its mmap, etc fields set.
      
      When we were adding the "dummy" event using perf_evlist__add_dummy() we
      were not setting it correctly, which could result in multiple tracking
      events.
      
      Now that I'll try using a dummy event to be the tracking one when using
      'perf record --delay', i.e. when we process the --delay
      setting we may already have the evlist set up, like with:
      
        perf record -e cycles,instructions --delay 1000 ./workload
      
      We will need to add a "dummy" event, then reset evsel->tracking for the
      first event, "cycles", and set it instead to the dummy one, and also
      setting its attr.enable_on_exec, so that we get the PERF_RECORD_MMAP,
      etc metadata events while waiting to enable the explicitely requested
      events, so lets get this straight and set the right evsel->idx.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Bram Stolk <b.stolk@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-nrdfchshqxf7diszhxcecqb9@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      555b4ec4
  5. 17 11月, 2017 2 次提交
  6. 13 11月, 2017 1 次提交
    • A
      perf evlist: Set the correct idx when adding dummy events · 640d5175
      Arnaldo Carvalho de Melo 提交于
      The evsel->idx field is used mainly to access the right bucket in
      per-event arrays such as the annotation ones, but also to set
      evsel->tracking, that in turn will decide what of the events will ask
      for PERF_RECORD_{MMAP,COMM,EXEC} to be generated, i.e. which
      perf_event_attr will have its mmap, etc fields set.
      
      When we were adding the "dummy" event using perf_evlist__add_dummy() we
      were not setting it correctly, which could result in multiple tracking
      events.
      
      Now that I'll try using a dummy event to be the tracking one when using
      'perf record --delay', i.e. when we process the --delay
      setting we may already have the evlist set up, like with:
      
        perf record -e cycles,instructions --delay 1000 ./workload
      
      We will need to add a "dummy" event, then reset evsel->tracking for the
      first event, "cycles", and set it instead to the dummy one, and also
      setting its attr.enable_on_exec, so that we get the PERF_RECORD_MMAP,
      etc metadata events while waiting to enable the explicitely requested
      events, so lets get this straight and set the right evsel->idx.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Bram Stolk <b.stolk@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-nrdfchshqxf7diszhxcecqb9@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      640d5175
  7. 23 10月, 2017 1 次提交
  8. 22 8月, 2017 1 次提交
    • A
      perf evsel: Fix buffer overflow while freeing events · 475fb533
      Andi Kleen 提交于
      Fix buffer overflow for:
      
        % perf stat -e msr/tsc/,cstate_core/c7-residency/ true
      
      that causes glibc free list corruption. For some reason it doesn't
      trigger in valgrind, but it is visible in AS:
      
        =================================================================
        ==32681==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x603000003f5c at pc 0x0000005671ef bp 0x7ffdaaac9ac0 sp 0x7ffdaaac9ab0
        READ of size 4 at 0x603000003f5c thread T0
          #0 0x5671ee in perf_evsel__close_fd util/evsel.c:1196
          #1 0x56c57a in perf_evsel__close util/evsel.c:1717
          #2 0x55ed5f in perf_evlist__close util/evlist.c:1631
          #3 0x4647e1 in __run_perf_stat /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:749
          #4 0x4648e3 in run_perf_stat /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:767
          #5 0x46e1bc in cmd_stat /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:2785
          #6 0x52f83d in run_builtin /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:296
          #7 0x52fd49 in handle_internal_command /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:348
          #8 0x5300de in run_argv /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:392
          #9 0x5308f3 in main /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:530
          #10 0x7f0672d13400 in __libc_start_main (/lib64/libc.so.6+0x20400)
          #11 0x428419 in _start (/home/ak/hle/obj-perf/perf+0x428419)
      
        0x603000003f5c is located 0 bytes to the right of 28-byte region [0x603000003f40,0x603000003f5c)
        allocated by thread T0 here:
          #0 0x7f0675139020 in calloc (/lib64/libasan.so.3+0xc7020)
          #1 0x648a2d in zalloc util/util.h:23
          #2 0x648a88 in xyarray__new util/xyarray.c:9
          #3 0x566419 in perf_evsel__alloc_fd util/evsel.c:1039
          #4 0x56b427 in perf_evsel__open util/evsel.c:1529
          #5 0x56c620 in perf_evsel__open_per_thread util/evsel.c:1730
          #6 0x461dea in create_perf_stat_counter /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:263
          #7 0x4637d7 in __run_perf_stat /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:600
          #8 0x4648e3 in run_perf_stat /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:767
          #9 0x46e1bc in cmd_stat /home/ak/hle/linux-hle-2.6/tools/perf/builtin-stat.c:2785
          #10 0x52f83d in run_builtin /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:296
          #11 0x52fd49 in handle_internal_command /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:348
          #12 0x5300de in run_argv /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:392
          #13 0x5308f3 in main /home/ak/hle/linux-hle-2.6/tools/perf/perf.c:530
          #14 0x7f0672d13400 in __libc_start_main (/lib64/libc.so.6+0x20400)
      
      The event is allocated with cpus == 1, but freed with cpus == real number
      When the evsel close function walks the file descriptors it exceeds the
      fd xyarray boundaries and reads random memory.
      
      v2:
      
      Now that xyarrays save their original dimensions we can use these to
      iterate the two dimensional fd arrays. Fix some users (close, ioctl) in
      evsel.c to use these fields directly. This allows simplifying the code
      and dropping quite a few function arguments. Adjust all callers by
      removing the unneeded arguments.
      
      The actual perf event reading still uses the original values from the
      evsel list.
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Link: http://lkml.kernel.org/r/20170811232634.30465-2-andi@firstfloor.org
      [ Fix up xy_max_[xy]() -> xyarray__max_[xy]() ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      475fb533
  9. 19 7月, 2017 2 次提交
  10. 25 4月, 2017 1 次提交
  11. 21 4月, 2017 2 次提交
  12. 20 4月, 2017 2 次提交
  13. 04 3月, 2017 2 次提交
  14. 12 1月, 2017 3 次提交
  15. 03 10月, 2016 1 次提交
    • A
      perf tools: Experiment with cppcheck · 18ef15c6
      Arnaldo Carvalho de Melo 提交于
      Experimenting a bit using cppcheck[1], a static checker brought to my
      attention by Colin, reducing the scope of some variables, reducing the
      line of source code lines in the process:
      
        $ cppcheck --enable=style tools/perf/util/thread.c
        Checking tools/perf/util/thread.c...
        [tools/perf/util/thread.c:17]: (style) The scope of the variable 'leader' can be reduced.
        [tools/perf/util/thread.c:133]: (style) The scope of the variable 'err' can be reduced.
        [tools/perf/util/thread.c:273]: (style) The scope of the variable 'err' can be reduced.
      
      Will continue later, but these are already useful, keep them.
      
      1: https://sourceforge.net/p/cppcheck/wiki/Home/
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Colin Ian King <colin.king@canonical.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-ixws7lbycihhpmq9cc949ti6@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      18ef15c6
  16. 09 9月, 2016 1 次提交
    • M
      perf evlist: Only open events on CPUs an evsel permits · 9f21b815
      Mark Rutland 提交于
      In systems with heterogeneous CPU PMUs, it's possible for each evsel to
      cover a distinct set of CPUs, and hence the cpu_map associated with each
      evsel may have a distinct idx<->id mapping. Any of these may be distinct
      from the evlist's cpu map.
      
      Events can be tied to the same fd so long as they use the same per-cpu
      ringbuffer (i.e. so long as they are on the same CPU). To acquire the
      correct FDs, we must compare the Linux logical IDs rather than the evsel
      or evlist indices.
      
      This path adds logic to perf_evlist__mmap_per_evsel to handle this,
      translating IDs as required. As PMUs may cover a subset of CPUs from the
      evlist, we skip the CPUs a PMU cannot handle.
      
      Without this patch, perf record may try to mmap erroneous FDs on
      heterogeneous systems, and will bail out early rather than running the
      workload.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will.deacon@arm.com>
      Link: http://lkml.kernel.org/r/1473330112-28528-7-git-send-email-mark.rutland@arm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9f21b815
  17. 29 7月, 2016 1 次提交
  18. 16 7月, 2016 9 次提交
  19. 13 7月, 2016 1 次提交