1. 18 12月, 2015 2 次提交
  2. 07 10月, 2015 1 次提交
  3. 01 10月, 2015 2 次提交
  4. 29 9月, 2015 1 次提交
    • A
      perf tools: Use __map__is_kernel() when synthesizing kernel module mmap records · ab9c2bdc
      Arnaldo Carvalho de Melo 提交于
      Equivalent and removes one more case of using dso->kernel.
      
        # perf record -a usleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.768 MB perf.data (30 samples) ]
      
      Before:
      
        [root@zoo ~]# perf script --show-task --show-mmap | head -3
         swapper 0 [0] 0.0: PERF_RECORD_MMAP -1/0: [0xffffffff81000000(0x1f000000) @ 0xffffffff81000000]: x [kernel.kallsyms]_text
         swapper 0 [0] 0.0: PERF_RECORD_MMAP -1/0: [0xffffffffa0000000(0xa000) @ 0]: x /lib/modules/4.3.0-rc1+/kernel/drivers/acpi/video.ko
         swapper 0 [0] 0.0: PERF_RECORD_MMAP -1/0: [0xffffffffa000a000(0x5000) @ 0]: x /lib/modules/4.3.0-rc1+/kernel/drivers/i2c/algos/i2c-algo-bit.ko
        #
      
        # perf script --show-task --show-mmap | head -3
         swapper 0 [0] 0.0: PERF_RECORD_MMAP -1/0: [0xffffffff81000000(0x1f000000) @ 0xffffffff81000000]: x [kernel.kallsyms]_text
         swapper 0 [0] 0.0: PERF_RECORD_MMAP -1/0: [0xffffffffa0000000(0xa000) @ 0]: x /lib/modules/4.3.0-rc1+/kernel/drivers/acpi/video.ko
         swapper 0 [0] 0.0: PERF_RECORD_MMAP -1/0: [0xffffffffa000a000(0x5000) @ 0]: x /lib/modules/4.3.0-rc1+/kernel/drivers/i2c/algos/i2c-algo-bit.ko
        #
      
      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>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-b65xe578dwq22mzmmj5y94wr@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ab9c2bdc
  5. 23 9月, 2015 1 次提交
    • N
      perf record: Synthesize COMM event for a command line workload · e803cf97
      Namhyung Kim 提交于
      When perf creates a new child to profile, the events are enabled on
      exec().  And in this case, it doesn't synthesize any event for the
      child since they'll be generated during exec().  But there's an window
      between the enabling and the event generation.
      
      It used to be overcome since samples are only in kernel (so we always
      have the map) and the comm is overridden by a later COMM event.
      However it won't work if events are processed and displayed before the
      COMM event overrides like in 'perf script'.  This leads to those early
      samples (like native_write_msr_safe) not having a comm but pid (like
      ':15328').
      
      So it needs to synthesize COMM event for the child explicitly before
      enabling so that it can have a correct comm.  But at this time, the
      comm will be "perf" since it's not exec-ed yet.
      
      Committer note:
      
      Before this patch:
      
        # perf record usleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.017 MB perf.data (7 samples) ]
        # perf script --show-task-events
          :4429  4429 27909.079372:          1 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
          :4429  4429 27909.079375:          1 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
          :4429  4429 27909.079376:         10 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
          :4429  4429 27909.079377:        223 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
          :4429  4429 27909.079378:       6571 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
         usleep  4429 27909.079380: PERF_RECORD_COMM exec: usleep:4429/4429
         usleep  4429 27909.079381:     185403 cycles:  ffffffff810a72d3 flush_signal_handlers (/lib/modules/4.
         usleep  4429 27909.079444:    2241110 cycles:      7fc575355be3 _dl_start (/usr/lib64/ld-2.20.so)
         usleep  4429 27909.079875: PERF_RECORD_EXIT(4429:4429):(4429:4429)
      
      After:
      
        # perf record usleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.017 MB perf.data (7 samples) ]
        # perf script --show-task
           perf     0     0.000000: PERF_RECORD_COMM: perf:8446/8446
           perf  8446 30154.038944:          1 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
           perf  8446 30154.038948:          1 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
           perf  8446 30154.038949:          9 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
           perf  8446 30154.038950:        230 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
           perf  8446 30154.038951:       6772 cycles:  ffffffff8105f45a native_write_msr_safe (/lib/modules/4.
         usleep  8446 30154.038952: PERF_RECORD_COMM exec: usleep:8446/8446
         usleep  8446 30154.038954:     196923 cycles:  ffffffff81766440 _raw_spin_lock (/lib/modules/4.3.0-rc1
         usleep  8446 30154.039021:    2292130 cycles:      7f609a173dc4 memcpy (/usr/lib64/ld-2.20.so)
         usleep  8446 30154.039349: PERF_RECORD_EXIT(8446:8446):(8446:8446)
        #
      Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1442881495-2928-1-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e803cf97
  6. 14 9月, 2015 1 次提交
  7. 24 7月, 2015 1 次提交
  8. 24 6月, 2015 1 次提交
  9. 20 6月, 2015 2 次提交
  10. 07 6月, 2015 1 次提交
    • K
      perf tools: handle PERF_RECORD_LOST_SAMPLES · c4937a91
      Kan Liang 提交于
      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: NKan Liang <kan.liang@intel.com>
      Signed-off-by: NPeter 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: NIngo Molnar <mingo@kernel.org>
      c4937a91
  11. 28 5月, 2015 1 次提交
  12. 27 5月, 2015 1 次提交
  13. 09 5月, 2015 1 次提交
    • A
      perf machine: Protect the machine->threads with a rwlock · b91fc39f
      Arnaldo Carvalho de Melo 提交于
      In addition to using refcounts for the struct thread lifetime
      management, we need to protect access to machine->threads from
      concurrent access.
      
      That happens in 'perf top', where a thread processes events, inserting
      and deleting entries from that rb_tree while another thread decays
      hist_entries, that end up dropping references and ultimately deleting
      threads from the rb_tree and releasing its resources when no further
      hist_entry (or other data structures, like in 'perf sched') references
      it.
      
      So the rule is the same for refcounts + protected trees in the kernel,
      get the tree lock, find object, bump the refcount, drop the tree lock,
      return, use object, drop the refcount if no more use of it is needed,
      keep it if storing it in some other data structure, drop when releasing
      that data structure.
      
      I.e. pair "t = machine__find(new)_thread()" with a "thread__put(t)", and
      "perf_event__preprocess_sample(&al)" with "addr_location__put(&al)".
      
      The addr_location__put() one is because as we return references to
      several data structures, we may end up adding more reference counting
      for the other data structures and then we'll drop it at
      addr_location__put() time.
      Acked-by: NDavid Ahern <dsahern@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      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-bs9rt4n0jw3hi9f3zxyy3xln@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b91fc39f
  14. 06 5月, 2015 2 次提交
  15. 29 4月, 2015 2 次提交
  16. 10 4月, 2015 2 次提交
  17. 01 4月, 2015 2 次提交
  18. 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
  19. 25 2月, 2015 1 次提交
  20. 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
  21. 26 9月, 2014 1 次提交
  22. 23 8月, 2014 1 次提交
  23. 25 7月, 2014 1 次提交
  24. 17 7月, 2014 2 次提交
  25. 09 6月, 2014 2 次提交
  26. 12 5月, 2014 1 次提交
  27. 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
  28. 19 3月, 2014 3 次提交