1. 17 Jun, 2015 2 commits
    • Wang Nan's avatar
      perf tools: Fix a problem when opening old perf.data with different byte order · b30b6172
      Wang Nan authored
      Following error occurs when trying to use 'perf report' on x86_64 to
      cross analysis a perf.data generated by an old perf on a big-endian
      machine:
      
       # perf report
       *** Error in `/home/w00229757/perf': free(): invalid next size (fast): 0x00000000032c99f0 ***
       ======= Backtrace: =========
       /lib64/libc.so.6(+0x6eeef)[0x7ff6ff7e2eef]
       /lib64/libc.so.6(+0x78cae)[0x7ff6ff7eccae]
       /lib64/libc.so.6(+0x79987)[0x7ff6ff7ed987]
       /path/to/perf[0x4ac734]
       /path/to/perf[0x4ac829]
       /path/to/perf(perf_header__process_sections+0x129)[0x4ad2c9]
       /path/to/perf(perf_session__read_header+0x2e1)[0x4ad9e1]
       /path/to/perf(perf_session__new+0x168)[0x4bd458]
       /path/to/perf(cmd_report+0xfa0)[0x43eb70]
       /path/to/perf[0x47adc3]
       /path/to/perf(main+0x5f6)[0x42fd06]
       /lib64/libc.so.6(__libc_start_main+0xf5)[0x7ff6ff795bd5]
       /path/to/perf[0x42fe35]
       ======= Memory map: ========
       [SNIP]
      
      The bug is in perf_event__attr_swap(). It swaps all fields in 'struct
      perf_event_attr' without checking whether the swapped field exist or
      not. In addition, in read_event_desc() allocs memory for attr according
      to size read from perf.data.
      
      Therefore, if the perf.data is collected by an old perf (without
      aux_watermark, for example), when perf_event__attr_swap() swaping
      attr->aux_watermark it destroy malloc's metadata.
      
      This patch introduces boundary checking in perf_event__attr_swap(). It
      adds macros bswap_field_64 and bswap_field_32 into
      perf_event__attr_swap() to make it only swap exist fields.
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1434534999-85347-1-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b30b6172
    • Wang Nan's avatar
      perf tools: Ignore .config-detected in .gitignore · 38629973
      Wang Nan authored
      Commit fcfd6611 ("tools build: Add
      detected config support") dynamically creates .config-detected. Add it
      to .gitignore.
      Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Link: http://lkml.kernel.org/r/1434542358-5430-1-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      38629973
  2. 16 Jun, 2015 9 commits
  3. 12 Jun, 2015 4 commits
    • Masami Hiramatsu's avatar
      perf probe: Cut off the gcc optimization postfixes from function name · 35a23ff9
      Masami Hiramatsu authored
      Cut off the postfixes which gcc added for optimized routines from the
      event name automatically generated from symbol name, since *probe-events
      doesn't accept it.  Those symbols will be used if we don't use debuginfo
      to find target functions.
      
      E.g. without this fix;
        -----
        # perf probe -va alloc_buf.isra.23
        probe-definition(0): alloc_buf.isra.23
        symbol:alloc_buf.isra.23 file:(null) line:0 offset:0 return:0 lazy:(null)
        [...]
        Opening /sys/kernel/debug/tracing/kprobe_events write=1
        Added new event:
        Writing event: p:probe/alloc_buf.isra.23 _text+4869328
        Failed to write event: Invalid argument
          Error: Failed to add events. Reason: Invalid argument (Code: -22)
        -----
      With this fix;
        -----
        perf probe -va alloc_buf.isra.23
        probe-definition(0): alloc_buf.isra.23
        symbol:alloc_buf.isra.23 file:(null) line:0 offset:0 return:0 lazy:(null)
        [...]
        Opening /sys/kernel/debug/tracing/kprobe_events write=1
        Added new event:
        Writing event: p:probe/alloc_buf _text+4869328
          probe:alloc_buf      (on alloc_buf.isra.23)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:alloc_buf -aR sleep 1
      
        -----
      Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naohiro Aota <naota@elisp.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20150612050820.20548.41625.stgit@localhost.localdomainSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      35a23ff9
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo' of... · 61d67d56
      Ingo Molnar authored
      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:
      
      User visible changes:
      
        - Beautify the perf_event_open() syscall in 'perf trace'. (Arnaldo Carvalho de Melo)
      
        - Error out unsupported group leader immediately in 'perf stat'. (Kan Liang)
      
        - Amend some 'perf record' option summaries (period, etc). (Peter Zijlstra)
      
        - Avoid possible race condition in copyfile() in 'perf buildid-cache'. (Milos Vyletel)
      
      Infrastructure changes:
      
        - Display 0x for hex values when printing the attribute. (Adrian Hunter)
      
        - Update MANIFEST per files removed from kernel. (David Ahern)
      
      Build fixes:
      
        - Fix PRIu64 printf related failure on 32-bit arch. (He Kuang)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      61d67d56
    • David Ahern's avatar
      perf tools: Update MANIFEST per files removed from kernel · c8ad7063
      David Ahern authored
      Building perf out of kernel tree is currently broken because the
      MANIFEST file refers to kernel files that have been removed. With this
      patch make perf-targz-src-pkg succeeds as does building perf using the
      generated tarfile.
      Signed-off-by: default avatarDavid Ahern <david.ahern@oracle.com>
      Link: http://lkml.kernel.org/r/1433526173-172332-1-git-send-email-david.ahern@oracle.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c8ad7063
    • Arnaldo Carvalho de Melo's avatar
      trace: Beautify perf_event_open syscall · a1c2552d
      Arnaldo Carvalho de Melo authored
      Syswide tracing and then running 'stat' and 'trace':
      
       $ perf trace -e perf_event_open
       1034.649 (0.019 ms): perf/6133 perf_event_open(attr_uptr: 0x36f0360, pid: 16134, cpu: -1, group_fd: -1, flags: FD_CLOEXEC) = -1 EINVAL Invalid argument
       1034.670 (0.008 ms): perf/6133 perf_event_open(attr_uptr: 0x36f0360, pid: 16134, cpu: -1, group_fd: -1) = -1 EINVAL Invalid argument
       1034.681 (0.007 ms): perf/6133 perf_event_open(attr_uptr: 0x36f0360, pid: 16134, cpu: -1, group_fd: -1) = -1 EINVAL Invalid argument
       1034.692 (0.007 ms): perf/6133 perf_event_open(attr_uptr: 0x36f0360, pid: 16134, cpu: -1, group_fd: -1) = -1 EINVAL Invalid argument
       9986.983 (0.014 ms): trace/6139 perf_event_open(attr_uptr: 0x7ffd9c629320, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 3
       9987.026 (0.016 ms): trace/6139 perf_event_open(attr_uptr: 0x37c7e70, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 3
       9987.041 (0.008 ms): trace/6139 perf_event_open(attr_uptr: 0x37c7e70, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 3
       9987.489 (0.092 ms): trace/6139 perf_event_open(attr_uptr: 0x3795ee0, pid: 16140, group_fd: -1, flags: FD_CLOEXEC) = 3
       9987.536 (0.044 ms): trace/6139 perf_event_open(attr_uptr: 0x3795ee0, pid: 16140, cpu: 1, group_fd: -1, flags: FD_CLOEXEC) = 4
       9987.580 (0.041 ms): trace/6139 perf_event_open(attr_uptr: 0x3795ee0, pid: 16140, cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 5
       9987.620 (0.037 ms): trace/6139 perf_event_open(attr_uptr: 0x3795ee0, pid: 16140, cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 7
       9987.659 (0.035 ms): trace/6139 perf_event_open(attr_uptr: 0x37975d0, pid: 16140, group_fd: -1, flags: FD_CLOEXEC) = 8
       9987.692 (0.031 ms): trace/6139 perf_event_open(attr_uptr: 0x37975d0, pid: 16140, cpu: 1, group_fd: -1, flags: FD_CLOEXEC) = 9
       9987.727 (0.032 ms): trace/6139 perf_event_open(attr_uptr: 0x37975d0, pid: 16140, cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 10
       9987.761 (0.031 ms): trace/6139 perf_event_open(attr_uptr: 0x37975d0, pid: 16140, cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 11
      
      Need to intercept perf_copy_attr() with a kprobe or with eBPF...
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/n/tip-njb105hab2i3t5dexym9lskl@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a1c2552d
  4. 11 Jun, 2015 3 commits
  5. 10 Jun, 2015 2 commits
  6. 09 Jun, 2015 1 commit
  7. 08 Jun, 2015 15 commits
  8. 07 Jun, 2015 4 commits
    • Peter Zijlstra's avatar
      perf/x86/intel/pebs: Add PEBSv3 decoding · a3d86542
      Peter Zijlstra authored
      PEBSv3 as present on Skylake fixed the long standing issue of the
      status bits. They now really reflect the events that generated the
      record.
      Tested-by: default avatarAndi Kleen <ak@linux.intel.com>
      Tested-by: default avatarKan Liang <kan.liang@intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      a3d86542
    • Kan Liang's avatar
      perf tools: handle PERF_RECORD_LOST_SAMPLES · c4937a91
      Kan Liang authored
      This patch modifies the perf tool to handle the new RECORD type,
      PERF_RECORD_LOST_SAMPLES.
      
      The number of lost-sample events is stored in
      .nr_events[PERF_RECORD_LOST_SAMPLES]. The exact number of samples
      which the kernel dropped is stored in total_lost_samples.
      
      When the percentage of dropped samples is greater than 5%, a warning
      is printed.
      
      Here are some examples:
      
      Eg 1, Recording different frequently-occurring events is safe with the
            patch. Only a very low drop rate is associated with such actions.
      
      $ perf record -e '{cycles:p,instructions:p}' -c 20003 --no-time ~/tchain ~/tchain
      
      $ perf report -D | tail
                SAMPLE events:     120243
                 MMAP2 events:          5
          LOST_SAMPLES events:         24
        FINISHED_ROUND events:         15
      cycles:p stats:
                 TOTAL events:      59348
                SAMPLE events:      59348
      instructions:p stats:
                 TOTAL events:      60895
                SAMPLE events:      60895
      
      $ perf report --stdio --group
       # To display the perf.data header info, please use --header/--header-only options.
       #
       #
       # Total Lost Samples: 24
       #
       # Samples: 120K of event 'anon group { cycles:p, instructions:p }'
       # Event count (approx.): 24048600000
       #
       #         Overhead  Command      Shared Object     Symbol
       # ................  ...........  ................
       ..................................
       #
          99.74%  99.86%  tchain_edit  tchain_edit       [.] f3
           0.09%   0.02%  tchain_edit  tchain_edit       [.] f2
           0.04%   0.00%  tchain_edit  [kernel.vmlinux]  [k] ixgbe_read_reg
      
      Eg 2, Recording the same thing multiple times can lead to high drop
            rate, but it is not a useful configuration.
      
      $ perf record -e '{cycles:p,cycles:p}' -c 20003 --no-time ~/tchain
      Warning: Processed 600592 samples and lost 99.73% samples!
      [perf record: Woken up 148 times to write data]
      [perf record: Captured and wrote 36.922 MB perf.data (1206322 samples)]
      [perf record: Woken up 1 times to write data]
      [perf record: Captured and wrote 0.121 MB perf.data (1629 samples)]
      Signed-off-by: default avatarKan Liang <kan.liang@intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: acme@infradead.org
      Cc: eranian@google.com
      Link: http://lkml.kernel.org/r/1431285195-14269-9-git-send-email-kan.liang@intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      c4937a91
    • Kan Liang's avatar
      perf/x86/intel: Introduce PERF_RECORD_LOST_SAMPLES · f38b0dbb
      Kan Liang authored
      After enlarging the PEBS interrupt threshold, there may be some mixed up
      PEBS samples which are discarded by the kernel.
      
      This patch makes the kernel emit a PERF_RECORD_LOST_SAMPLES record with
      the number of possible discarded records when it is impossible to demux
      the samples.
      
      It makes sure the user is not left in the dark about such discards.
      Signed-off-by: default avatarKan Liang <kan.liang@intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: acme@infradead.org
      Cc: eranian@google.com
      Link: http://lkml.kernel.org/r/1431285195-14269-8-git-send-email-kan.liang@intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      f38b0dbb
    • Yan, Zheng's avatar
      perf/intel/x86: Enlarge the PEBS buffer · 15617499
      Yan, Zheng authored
      Currently the PEBS buffer size is 4k, it can only hold about 21
      PEBS records. This patch enlarges the PEBS buffer size to 64k
      (the same as the BTS buffer).
      
      64k memory can hold about 330 PEBS records. This will significantly
      reduce the number of PMIs when batched PEBS interrupts are enabled.
      Signed-off-by: default avatarYan, Zheng <zheng.z.yan@intel.com>
      Signed-off-by: default avatarKan Liang <kan.liang@intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: acme@infradead.org
      Cc: eranian@google.com
      Link: http://lkml.kernel.org/r/1430940834-8964-7-git-send-email-kan.liang@intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      15617499