1. 10 4月, 2015 1 次提交
  2. 01 4月, 2015 2 次提交
  3. 02 3月, 2015 1 次提交
    • 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
  4. 25 2月, 2015 1 次提交
  5. 29 10月, 2014 2 次提交
    • A
      perf tools: Add id index · 3c659eed
      Adrian Hunter 提交于
      Add an index of the event identifiers, in preparation for Intel PT.
      
      The event id (also called the sample id) is a unique number
      allocated by the kernel to the event created by perf_event_open().  Events
      can include the event id by having a sample type including PERF_SAMPLE_ID or
      PERF_SAMPLE_IDENTIFIER.
      
      Currently the main use of the event id is to match an event back to the
      evsel to which it belongs i.e. perf_evlist__id2evsel()
      
      The purpose of this patch is to make it possible to match an event back to
      the mmap from which it was read.  The reason that is useful is because the
      mmap represents a time-ordered context (either for a cpu or for a thread).
      Intel PT decodes trace information on that basis.  In full-trace mode, that
      information can be recorded when the Intel PT trace is read, but in
      sample-mode the Intel PT trace data is embedded in a sample and it is in
      that case that the "id index" is needed.
      
      So the mmaps are numbered (idx) and the cpu and tid recorded against the id
      by perf_evlist__set_sid_idx() which is called by perf_evlist__mmap_per_evsel().
      
      That information is recorded on the perf.data file in the new "id index".
      idx, cpu and tid are added to struct perf_sample_id (which is the node of
      evlist's hash table to match ids to evsels).  The information can be
      retrieved using perf_evlist__id2sid().  Note however this all depends on
      having a sample type including PERF_SAMPLE_ID or PERF_SAMPLE_IDENTIFIER,
      otherwise ids are not recorded.
      
      The "id index" is a synthesized event record which will be created when
      Intel PT sampling is used by calling perf_event__synthesize_id_index().
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1414417770-18602-2-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3c659eed
    • A
      perf tools: A thread's machine can be found via thread->mg->machine · bb871a9c
      Arnaldo Carvalho de Melo 提交于
      So stop passing both machine and thread to several thread methods,
      reducing function signature length.
      
      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: Jean Pihet <jean.pihet@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-ckcy19dcp1jfkmdihdjcqdn1@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bb871a9c
  6. 26 9月, 2014 1 次提交
  7. 23 8月, 2014 1 次提交
  8. 25 7月, 2014 1 次提交
  9. 17 7月, 2014 2 次提交
  10. 09 6月, 2014 2 次提交
  11. 12 5月, 2014 1 次提交
  12. 28 4月, 2014 1 次提交
    • A
      perf tools: Allocate thread map_groups's dynamically · 93d5731d
      Arnaldo Carvalho de Melo 提交于
      Moving towards sharing map groups within a process threads.
      
      Because of this we need the map groups to be dynamically allocated. No
      other functional change is intended in here.
      
      Based on a patch by Jiri Olsa, but this time _just_ making the
      conversion from statically allocating thread->mg to turning it into a
      pointer and instead of initializing it at thread's constructor,
      introduce a constructor/destructor for the map_groups class and
      call at thread creation time.
      
      Later we will introduce the get/put methods when we move to sharing
      those map_groups, when the get/put refcounting semantics will be needed.
      Signed-off-by: NArnaldo Carvalho de Melo <acme@kernel.org>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Mike Galbraith <efault@gmx.de>
      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/1397490723-1992-3-git-send-email-jolsa@redhat.comSigned-off-by: NJiri Olsa <jolsa@kernel.org>
      93d5731d
  13. 19 3月, 2014 3 次提交
  14. 15 3月, 2014 1 次提交
  15. 14 3月, 2014 1 次提交
    • D
      perf tools: Fix synthesizing mmaps for threads · bfd66cc7
      Don Zickus 提交于
      Currently if a process creates a bunch of threads using pthread_create
      and then perf is run in system_wide mode, the mmaps for those threads
      are not captured with a synthesized mmap event.
      
      The reason is those threads are not visible when walking the /proc/
      directory looking for /proc/<pid>/maps files.  Instead they are
      discovered using the /proc/<pid>/tasks file (which the synthesized comm
      event uses).
      
      This causes problems when a program is trying to map a data address to a
      tid.  Because the tid has no maps, the event is dropped.  Changing the
      program to look up using the pid instead of the tid, finds the correct
      maps but creates ugly hacks in the program to carry the correct tid
      around.
      
      Fix this by moving the walking of the /proc/<pid>/tasks up a level (out
      of the comm function) based on Arnaldo's suggestion.
      
      Tweaked things a bit to special case the 'full' bit and 'guest' check.
      Signed-off-by: NDon Zickus <dzickus@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1393429527-167840-2-git-send-email-dzickus@redhat.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bfd66cc7
  16. 01 2月, 2014 2 次提交
  17. 13 1月, 2014 1 次提交
  18. 24 12月, 2013 5 次提交
  19. 20 12月, 2013 1 次提交
    • A
      perf symbols: Add 'machine' member to struct addr_location · cc22e575
      Arnaldo Carvalho de Melo 提交于
      The addr_location struct should fully qualify an address, and to do that
      it should have in it the machine where the thread was found.
      
      Thus all functions that receive an addr_location now don't need to also
      receive a 'machine', those functions just need to access al->machine
      instead, just like it does with the other parts of an address location:
      al->thread, al->map, etc.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-o51iiee7vyq4r3k362uvuylg@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cc22e575
  20. 13 12月, 2013 1 次提交
  21. 28 11月, 2013 1 次提交
  22. 15 11月, 2013 1 次提交
    • D
      perf tools: Synthesize anon MMAP records again · 9d4ecc88
      Don Zickus 提交于
      When introducing the PERF_RECORD_MMAP2 in:
      
      5c5e854b perf tools: Add attr->mmap2 support
      
      A check for the number of entries parsed by sscanf was introduced that
      assumed all of the 8 fields needed to be correctly parsed so that
      particular /proc/pid/maps line would be considered synthesizable.
      
      That broke anon records synthesizing, as it doesn't have the 'execname'
      field.
      
      Fix it by keeping the sscanf return check, changing it to not require
      that the 'execname' variable be parsed, so that the preexisting logic
      can kick in and set it to '//anon'.
      
      This should get things like JIT profiling working again.
      Signed-off-by: NDon Zickus <dzickus@redhat.com>
      Cc: Bill Gray <bgray@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Joe Mario <jmario@redhat.com>
      Cc: Richard Fowles <rfowles@redhat.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: stable@vger.kernel.org
      Link: http://lkml.kernel.org/n/tip-bo4akalno7579shpz29u867j@git.kernel.org
      [ commit log message is mine, dzickus reported the problem with a patch ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9d4ecc88
  23. 12 11月, 2013 1 次提交
  24. 06 11月, 2013 1 次提交
  25. 04 11月, 2013 2 次提交
  26. 28 10月, 2013 1 次提交
  27. 18 10月, 2013 1 次提交
    • S
      perf: Disable PERF_RECORD_MMAP2 support · 3090ffb5
      Stephane Eranian 提交于
      For now, we disable the extended MMAP record support (MMAP2).
      
      We have identified cases where it would not report the correct mapping
      information, clone(VM_CLONE) but with separate pids.  We will revisit
      the support once we find a solution for this case.
      
      The patch changes the kernel to return EINVAL if attr->mmap2 is set. The
      patch also modifies the perf tool to use regular PERF_RECORD_MMAP for
      synthetic events and it also prevents the tool from requesting
      attr->mmap2 mode because the kernel would reject it.
      
      The support will be revisited once the kenrel interface is updated.
      
      In V2, we reduce the patch to the strict minimum.
      
      In V3, we avoid calling perf_event_open() with mmap2 set because we know
      it will fail and require fallback retry.
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20131017173215.GA8820@quadSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3090ffb5
  28. 11 9月, 2013 1 次提交
    • S
      perf tools: Add attr->mmap2 support · 5c5e854b
      Stephane Eranian 提交于
      This patch adds support for the new PERF_RECORD_MMAP2 record type
      exposed by the kernel. This is an extended PERF_RECORD_MMAP record.
      
      It adds for each file-backed mapping the device major, minor number and
      the inode number and generation.
      
      This triplet uniquely identifies the source of a file-backed mapping. It
      can be used to detect identical virtual mappings between processes, for
      instance.
      
      The patch will prefer MMAP2 over MMAP.
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1377079825-19057-3-git-send-email-eranian@google.com
      [ Cope with 314add6b "Change machine__findnew_thread() to set thread pid",
        fix 'perf test' regression test entry affected,
        use perf_missing_features.mmap2 to fallback to not using .mmap2 in older kernels,
        so that new tools can work with kernels where this feature is not present ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5c5e854b