1. 23 3月, 2015 5 次提交
  2. 22 3月, 2015 6 次提交
  3. 21 3月, 2015 1 次提交
    • M
      perf tools: Fix race in build_id_cache__add_s() · 0635b0f7
      Milos Vyletel 提交于
      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: NMilos Vyletel <milos@redhat.com>
      Acked-by: NJiri 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: NArnaldo Carvalho de Melo <acme@redhat.com>
      0635b0f7
  4. 20 3月, 2015 2 次提交
  5. 18 3月, 2015 2 次提交
  6. 13 3月, 2015 1 次提交
  7. 12 3月, 2015 12 次提交
  8. 11 3月, 2015 2 次提交
  9. 03 3月, 2015 1 次提交
    • A
      perf tools: Reference count struct thread · f3b623b8
      Arnaldo Carvalho de Melo 提交于
      We need to do that to stop accumulating entries in the dead_threads
      linked list, i.e. we were keeping references to threads in struct hists
      that continue to exist even after a thread exited and was removed from
      the machine threads rbtree.
      
      We still keep the dead_threads list, but just for debugging, allowing us
      to iterate at any given point over the threads that still are referenced
      by things like struct hist_entry.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-3ejvfyed0r7ue61dkurzjux4@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f3b623b8
  10. 02 3月, 2015 4 次提交
    • M
      perf probe: Remove bias offset to find probe point by address · 0104fe69
      Masami Hiramatsu 提交于
      Remove bias offset to find probe point by address.
      
      Without this patch, probe points on kernel and executables are shown
      correctly, but do not work with libraries:
      
        # ./perf probe -l
          probe:do_fork        (on do_fork@kernel/fork.c)
          probe_libc:malloc    (on malloc in /usr/lib64/libc-2.17.so)
          probe_perf:strlist__new (on strlist__new@util/strlist.c in /home/mhiramat/ksrc/linux-3/tools/perf/perf)
      
      Removing bias allows it to show it as real place:
      
        # ./perf probe -l
          probe:do_fork        (on do_fork@kernel/fork.c)
          probe_libc:malloc    (on __libc_malloc@malloc/malloc.c in /usr/lib64/libc-2.17.so)
          probe_perf:strlist__new (on strlist__new@util/strlist.c in /home/mhiramat/ksrc/linux-3/tools/perf/perf)
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.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/20150302124946.9191.64085.stgit@localhost.localdomainSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0104fe69
    • M
      perf probe: Warn if given uprobe event accesses memory on older kernel · 79702f61
      Masami Hiramatsu 提交于
      Warn if given uprobe event accesses memory on older kernel.
      
      Until 3.14, uprobe event only supports accessing registers so this warns
      to upgrade kernel if uprobe-event returns -EINVAL and an argument of the
      event accesses memory ($stack, @+offset, and +|-offs() symtax).
      
      With this patch (on 3.10.0-123.13.2.el7.x86_64);
        -----
        # ./perf probe -x ./perf warn_uprobe_event_compat stack=-0\(%sp\)
        Added new event:
        Failed to write event: Invalid argument
        Please upgrade your kernel to at least 3.14 to have access to feature -0(%sp)
          Error: Failed to add events.
        -----
      Suggested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/20150228025329.32106.70581.stgit@localhost.localdomainSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      79702f61
    • A
      perf tools: Fix FORK after COMM when synthesizing records for pre-existing threads · 4aa5f4f7
      Arnaldo Carvalho de Melo 提交于
      In this commit:
      
        commit 363b785f
        Author: Don Zickus <dzickus@redhat.com>
        Date:   Fri Mar 14 10:43:44 2014 -0400
      
            perf tools: Speed up thread map generation
      
      We ended up emitting PERF_RECORD_FORK events after their corresponding
      PERF_RECORD_COMM, so the code below will remove the "existing thread"
      and then recreates it, unnecessarily:
      
        [root@ssdandy ~]# perf probe -x ~/bin/perf -L machine__process_fork_event
        <machine__process_fork_event@/home/acme/git/linux/tools/perf/util/machine.c:0>
            0  int machine__process_fork_event(struct machine *machine, union perf_event *event,
                                              struct perf_sample *sample)
            2  {
            3         struct thread *thread = machine__find_thread(machine,
                                                                   event->fork.pid,
                                                                   event->fork.tid);
            6         struct thread *parent = machine__findnew_thread(machine,
                                                                      event->fork.ppid,
                                                                      event->fork.ptid);
      
                      /* if a thread currently exists for the thread id remove it */
                      if (thread != NULL)
           12                 machine__remove_thread(machine, thread);
      
           14         thread = machine__findnew_thread(machine, event->fork.pid,
                                                       event->fork.tid);
           16         if (dump_trace)
           17                 perf_event__fprintf_task(event, stdout);
      
           19         if (thread == NULL || parent == NULL ||
           20             thread__fork(thread, parent, sample->time) < 0) {
           21                 dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n");
           22                 return -1;
                      }
      
           25         return 0;
           26  }
      
        [root@ssdandy ~]# perf probe -x ~/bin/perf fork_after_comm=machine__process_fork_event:12
        Added new event:
          probe_perf:fork_after_comm (on machine__process_fork_event:12 in /home/acme/bin/perf)
      
        You can now use it in all perf tools, such as:
      
      	perf record -e probe_perf:fork_after_comm -aR sleep 1
      
        [root@ssdandy ~]#
      
        [root@ssdandy ~]# perf record -g -e probe_perf:* trace -o /tmp/bla
        ^C[ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.021 MB perf.data (30 samples) ]
        Terminated
        [root@ssdandy ~]#
      
        [root@ssdandy ~]# perf report --no-children --show-total-period --stdio
        # To display the perf.data header info, please use --header/--header-only options.
        #
        # Samples: 30  of event 'probe_perf:fork_after_comm'
        # Event count (approx.): 30
        #
        # Overhead        Period  Command  Shared Object  Symbol
        # ........  ............  .......  .............  ...............................
        #
           100.00%            30  trace    trace          [.] machine__process_fork_event
                      |
                      ---machine__process_fork_event
                         __event__synthesize_thread.part.2
                         perf_event__synthesize_threads
                         cmd_trace
                         main
                         __libc_start_main
      
        [root@ssdandy ~]#
      
        And Looking at 'perf report -D' output we see it:
      
        0 0 0x8698 [0x30]: PERF_RECORD_COMM: auditd:703/707
        0 0 0x86c8 [0x38]: PERF_RECORD_FORK(703:707):(703:703)
      
      Fix it by more closely mimicking how the kernel generates those records
      when a new fork happens, i.e. first a PERF_RECORD_FORK, then a
      PERF_RECORD_COMM.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-h0emvymi2t3mw8dlqd6d6z73@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4aa5f4f7
    • D
      perf tools: Only include tsc file for x86 · ecefde62
      David Ahern 提交于
      The perf_time_to_tsc and tsc_to_perf_time functions are only used for x86.
      
      Make inclusion of tsc.c dependent on x86 as well.
      Signed-off-by: NDavid Ahern <david.ahern@oracle.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <david.ahern@oracle.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Link: http://lkml.kernel.org/r/1424370153-128274-1-git-send-email-david.ahern@oracle.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ecefde62
  11. 28 2月, 2015 4 次提交