1. 20 Mar, 2015 1 commit
    • Milos Vyletel's avatar
      perf tools: Fix race in build_id_cache__add_s() · 0635b0f7
      Milos Vyletel authored
      int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
                                const char *name, bool is_kallsyms, bool is_vdso)
      {
      ...
              if (access(filename, F_OK)) {
                     ^--------------------------------------------------------- [1]
                      if (is_kallsyms) {
                               if (copyfile("/proc/kallsyms", filename))
                                      goto out_free;
                      } else if (link(realname, filename) && copyfile(name, filename))
                                   ^-----------------------------^------------- [2]
                                                                  \------------ [3]
                              goto out_free;
              }
      ...
      
      When multiple instances of perf record get to [1] at more or less same time and
      run access() one or more may get failure because the file does not exist yet
      (since the first instance did not have chance to link it yet).
      
      At this point the race moves to link() at [2] where first thread to get
      there links file and goes on but second one gets -EEXIST so it runs
      copyfile [3] which truncates the file.
      
      reproducer:
      
      rm -rf /root/.debug
      for cpu in $(awk '/processor/ {print $3}' /proc/cpuinfo); do
      	perf record -a -v -T -F 1000 -C $cpu \
      		-o perf-${cpu}.data sleep 5 2> /dev/null &
      done
      wait
      
      and simply search for empty files by:
      
      find /lib/modules/`uname -r`/kernel/* -size 0
      Signed-off-by: default avatarMilos Vyletel <milos@redhat.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1426847846-11112-1-git-send-email-milos@redhat.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0635b0f7
  2. 19 Mar, 2015 16 commits
  3. 18 Mar, 2015 11 commits
  4. 17 Mar, 2015 2 commits
  5. 16 Mar, 2015 2 commits
  6. 13 Mar, 2015 8 commits
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo' of... · 107eb964
      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 from Arnaldo Carvalho de Melo:
      
      User visible changes:
      
        - Fix UI bug after zoom into thread/dso/symbol and another, after fold/unfold,
          in the TUI hists browser (He Kuang)
      
        - Fixes for 'perf probe' to better handle aliased symbols, for instance in glibc (Masami Hiramatsu, Namhyung Kim)
      
        - 'perf kmem' improvements and fixes: (Namhyung Kim)
          - Fix segfault when invalid sort key is given
          - Allow -v option
          - Fix alignment of slab result table
      
        - 'perf stat' improvements and fixes: (Andi Kleen)
          - Output running time and run/enabled ratio in CSV mode
          - Fix IPC and other formulas with -A
          - Always correctly indent ratio column
      
        - Add tracepoint events fields CTF conversion support to 'perf data' (Sebastian Andrzej Siewior)
      
      Infrastructure changes:
      
        - Output feature detection's gcc output to a file, to help in debugging (Arnaldo Carvalho de Melo)
      
        - Fix 'perf probe' compiles due to declarations using perf_probe_point (David Ahern)
      
        - Fix possible double free on error in 'perf probe' (He Kuang)
      
        - Remove superfluous thread->comm_set setting (Jiri Olsa)
      
        - Fix libbabeltrace detection (Jiri Olsa)
      
        - More work on separating ordered_events code out of perf_session (Arnaldo Carvalho de Melo)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      107eb964
    • Sebastian Andrzej Siewior's avatar
      perf data: Add tracepoint events fields CTF conversion support · 69364727
      Sebastian Andrzej Siewior authored
      Adding support to convert tracepoint event fields into CTF
      event fields.
      
      We parse each tracepoint event for CTF conversion and add
      tracepoint fields as regular CTF event fields, so they
      appear in babeltrace output like:
      
        $ babeltrace ./ctf-data/
        ...
        [09:02:00.950703057] (+?.?????????) sched:sched_stat_runtime: { }, { perf_ip = ... SNIP ... common_type = 298, common_flags = 1, \
        common_preempt_count = 0, common_pid = 31813, comm = "perf", pid = 31813, runtime = 458800, vruntime = 52059858071 }
        ...
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jeremie Galarneau <jgalar@efficios.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Tom Zanussi <tzanussi@gmail.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/r/1424470628-5969-6-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      69364727
    • Namhyung Kim's avatar
      perf kmem: Fix alignment of slab result table · 65f46e02
      Namhyung Kim authored
      Its table was a bit misaligned.  Fix it.
      
      Before:
      
        # perf kmem stat --caller -l 10
        ------------------------------------------------------------------------------------------------------
         Callsite                           | Total_alloc/Per | Total_req/Per   | Hit      | Ping-pong | Frag
        ------------------------------------------------------------------------------------------------------
         radeon_cs_parser_init.part.1+11a   |      2080/260   |      1504/188   |        8 |        0 | 27.692%
         radeon_cs_parser_init.part.1+e1    |       384/96    |       288/72    |        4 |        0 | 25.000%
         radeon_cs_parser_init.part.1+93    |       128/32    |        96/24    |        4 |        0 | 25.000%
         load_elf_binary+a39                |       512/512   |       392/392   |        1 |        0 | 23.438%
         __alloc_skb+89                     |      6144/877   |      4800/685   |        7 |        6 | 21.875%
         radeon_fence_emit+5c               |      1152/192   |       912/152   |        6 |        0 | 20.833%
         radeon_cs_parser_relocs+ad         |      8192/2048  |      6624/1656  |        4 |        0 | 19.141%
         radeon_sa_bo_new+78                |      1280/64    |      1120/56    |       20 |        0 | 12.500%
         load_elf_binary+2c4                |        32/32    |        28/28    |        1 |        0 | 12.500%
         anon_vma_prepare+101               |       576/72    |       512/64    |        8 |        0 | 11.111%
         ...                                | ...             | ...             | ...    | ...      | ...
        ------------------------------------------------------------------------------------------------------
      
      After:
      
        ---------------------------------------------------------------------------------------------------------
         Callsite                           | Total_alloc/Per | Total_req/Per   | Hit      | Ping-pong | Frag
        ---------------------------------------------------------------------------------------------------------
         radeon_cs_parser_init.part.1+11a   |      2080/260   |      1504/188   |        8 |         0 | 27.692%
         radeon_cs_parser_init.part.1+e1    |       384/96    |       288/72    |        4 |         0 | 25.000%
         radeon_cs_parser_init.part.1+93    |       128/32    |        96/24    |        4 |         0 | 25.000%
         load_elf_binary+a39                |       512/512   |       392/392   |        1 |         0 | 23.438%
         __alloc_skb+89                     |      6144/877   |      4800/685   |        7 |         6 | 21.875%
         radeon_fence_emit+5c               |      1152/192   |       912/152   |        6 |         0 | 20.833%
         radeon_cs_parser_relocs+ad         |      8192/2048  |      6624/1656  |        4 |         0 | 19.141%
         radeon_sa_bo_new+78                |      1280/64    |      1120/56    |       20 |         0 | 12.500%
         load_elf_binary+2c4                |        32/32    |        28/28    |        1 |         0 | 12.500%
         anon_vma_prepare+101               |       576/72    |       512/64    |        8 |         0 | 11.111%
         ...                                | ...             | ...             | ...      | ...       | ...
        ---------------------------------------------------------------------------------------------------------
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Joonsoo Kim <js1304@gmail.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1426145571-3065-4-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      65f46e02
    • Namhyung Kim's avatar
      perf kmem: Allow -v option · bd72a33e
      Namhyung Kim authored
      Current perf kmem fails when -v option is used.  As it's very useful for
      debugging, let's allow it.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joonsoo Kim <js1304@gmail.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1426145571-3065-3-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bd72a33e
    • Namhyung Kim's avatar
      perf kmem: Fix segfault when invalid sort key is given · 405f8755
      Namhyung Kim authored
      When it tries to free 'str', it was already updated by strsep() - so it
      needs to save the original pointer.
      
        # perf kmem stat -s xxx,hit
          Error: Unknown --sort key: 'xxx'
        *** Error in `perf': free(): invalid pointer: 0x0000000000e9e7b6 ***
        ======= Backtrace: =========
        /usr/lib/libc.so.6(+0x7198e)[0x7fc7e6e0d98e]
        /usr/lib/libc.so.6(+0x76dee)[0x7fc7e6e12dee]
        /usr/lib/libc.so.6(+0x775cb)[0x7fc7e6e135cb]
        ./perf[0x44a1b5]
        ./perf[0x490b20]
        ./perf(parse_options_step+0x173)[0x491773]
        ./perf(parse_options_subcommand+0xa7)[0x491fb7]
        ./perf(cmd_kmem+0x2bc)[0x44ae4c]
        ./perf[0x47aa13]
        ./perf(main+0x60a)[0x427a9a]
        /usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7fc7e6dbc800]
        ./perf(_start+0x29)[0x427bb9]
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joonsoo Kim <js1304@gmail.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1426145571-3065-2-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      405f8755
    • Andi Kleen's avatar
      perf stat: Always correctly indent ratio column · 79103528
      Andi Kleen authored
      When cycles or instructions do not print anything, as in being,
      --per-socket or --per-core modi, the ratio column was not correctly
      indented for them. This lead to some ratios not lining up with the
      others. Always indent correctly when nothing is printed.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Link: http://lkml.kernel.org/r/1426087682-22765-3-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      79103528
    • Andi Kleen's avatar
      perf stat: Fix IPC and other formulas with -A · 56f0fd45
      Andi Kleen authored
      perf stat didn't compute the IPC and other formulas for individual CPUs
      with -A. Fix this for the easy -A case. As before, --per-core and
      --per-socket do not handle it, they simply print nothing.
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Link: http://lkml.kernel.org/r/1426087682-22765-2-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      56f0fd45
    • Andi Kleen's avatar
      perf stat: Output running time and run/enabled ratio in CSV mode · d73515c0
      Andi Kleen authored
      The information how much a counter ran in 'perf stat' can be quite
      interesting for other tools to judge how trustworthy a measurement is.
      
      Currently it is only output in non CSV mode.
      
      This patches make perf stat always output the running time and the
      enabled/running ratio in CSV mode.
      
      This adds two new fields at the end for each line. I assume that
      existing tools ignore new fields at the end, so it's on by default.
      
      Only CSV mode is affected, no difference otherwise.
      
      v2: Add extra print_running function
      v3: Avoid printing nan
      v4: Remove some elses and add brackets.
      v5: Move non CSV case into print_running
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Reviewed-by: default avatarJiri Olsa <jolsa@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1426083387-17006-1-git-send-email-andi@firstfloor.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d73515c0