14 Mar, 2017

1 commit

  • Introduce a new option to record PERF_RECORD_NAMESPACES events emitted
    by the kernel when fork, clone, setns or unshare are invoked. And update
    perf-record documentation with the new option to record namespace
    events.

    Committer notes:

    Combined it with a later patch to allow printing it via 'perf report -D'
    and be able to test the feature introduced in this patch. Had to move
    here also perf_ns__name(), that was introduced in another later patch.

    Also used PRIu64 and PRIx64 to fix the build in some enfironments wrt:

    util/event.c:1129:39: error: format '%lx' expects argument of type 'long unsigned int', but argument 6 has type 'long long unsigned int' [-Werror=format=]
    ret += fprintf(fp, "%u/%s: %lu/0x%lx%s", idx
    ^
    Testing it:

    # perf record --namespaces -a
    ^C[ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 1.083 MB perf.data (423 samples) ]
    #
    # perf report -D

    3 2028902078892 0x115140 [0xa0]: PERF_RECORD_NAMESPACES 14783/14783 - nr_namespaces: 7
    [0/net: 3/0xf0000081, 1/uts: 3/0xeffffffe, 2/ipc: 3/0xefffffff, 3/pid: 3/0xeffffffc,
    4/user: 3/0xeffffffd, 5/mnt: 3/0xf0000000, 6/cgroup: 3/0xeffffffb]

    0x1151e0 [0x30]: event: 9
    .
    . ... raw event: size 48 bytes
    . 0000: 09 00 00 00 02 00 30 00 c4 71 82 68 0c 7f 00 00 ......0..q.h....
    . 0010: a9 39 00 00 a9 39 00 00 94 28 fe 63 d8 01 00 00 .9...9...(.c....
    . 0020: 03 00 00 00 00 00 00 00 ce c4 02 00 00 00 00 00 ................

    NAMESPACES events: 1

    #

    Signed-off-by: Hari Bathini
    Acked-by: Jiri Olsa
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: Alexei Starovoitov
    Cc: Ananth N Mavinakayanahalli
    Cc: Aravinda Prasad
    Cc: Brendan Gregg
    Cc: Daniel Borkmann
    Cc: Eric Biederman
    Cc: Peter Zijlstra
    Cc: Sargun Dhillon
    Cc: Steven Rostedt
    Link: http://lkml.kernel.org/r/148891930386.25309.18412039920746995488.stgit@hbathini.in.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Hari Bathini
     

31 Mar, 2016

1 commit

  • Intel PT uses the time members from the perf_event_mmap_page to convert
    between TSC and perf time.

    Due to a lack of foresight when Intel PT was implemented, those time
    members were recorded in the (implementation dependent) AUXTRACE_INFO
    event, the structure of which is generally inaccessible outside of the
    Intel PT decoder. However now the conversion between TSC and perf time
    is needed when processing a jitdump file when Intel PT has been used for
    tracing.

    So add a user event to record the time members. 'perf record' will
    synthesize the event if the information is available. And session
    processing will put a copy of the event on the session so that tools
    like 'perf inject' can easily access it.

    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1457426324-30158-1-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

18 Dec, 2015

6 commits

  • It'll serve as a base event for additional event attributes details,
    that are not part of the attr event.

    At the moment this event is just a dummy one without any specific
    functionality. The type value will distinguish the update event details.
    It'll come in the following patches.

    The idea for this event is to be extensible for any update that the
    event might need in the future.

    Signed-off-by: Jiri Olsa
    Tested-by: Kan Liang
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1445784728-21732-21-git-send-email-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • Adding the stat round event to be stored after each stat interval round,
    so that report tools (report/script) gets notified and process interval
    data.

    Signed-off-by: Jiri Olsa
    Tested-by: Kan Liang
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1445784728-21732-18-git-send-email-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • Adding a stat event to store a 'struct perf_counter_values' for a given
    event/cpu/thread.

    Signed-off-by: Jiri Olsa
    Tested-by: Kan Liang
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1445784728-21732-15-git-send-email-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • Adding the stat config event to pass/store stat config data, so report
    tools (report/script) know how to interpret stat data.

    The config data is stored in a 'tag|value' way to allow for easy
    extension and backwards compatibility.

    Signed-off-by: Jiri Olsa
    Tested-by: Kan Liang
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1445784728-21732-12-git-send-email-jolsa@kernel.org
    [ stat_config_term_event -> stat_config_event_entry ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • Adding the cpu_map event to pass/store cpu maps as data in
    a pipe/perf.data.

    We store maps in 2 formats:
    - list of cpus
    - mask of cpus

    The format that takes less space is selected transparently in the
    following patch.

    The interface is made generic, so we could add the cpumap event data
    into another event in the following patches.

    Signed-off-by: Jiri Olsa
    Tested-by: Kan Liang
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1445784728-21732-8-git-send-email-jolsa@kernel.org
    [ cpu_map_data_cpus -> cpu_map_entries, cpu_map_data_mask -> cpu_map_mask ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • Adding the thread_map event to pass/store thread maps as data in
    the pipe/perf.data.

    Storing the thread ID along with the standard comm[16] thread name string.

    Signed-off-by: Jiri Olsa
    Tested-by: Kan Liang
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1445784728-21732-4-git-send-email-jolsa@kernel.org
    [ Renamed thread_map_data_event to thread_map_event_entry ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     

24 Jul, 2015

1 commit

  • Support processing of PERF_RECORD_SWITCH events and
    PERF_RECORD_SWITCH_CPU_WIDE events. There is a single
    tools callback for them both so that the tool must
    check the event type before using the extra members
    in PERF_RECORD_SWITCH_CPU_WIDE.

    There is still no way to select the events, though.
    That is added in a subsequest patch.

    Signed-off-by: Adrian Hunter
    Acked-by: Peter Zijlstra (Intel)
    Tested-by: Jiri Olsa
    Cc: Andi Kleen
    Cc: Mathieu Poirier
    Cc: Pawel Moll
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1437471846-26995-3-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

07 Jun, 2015

1 commit

  • 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: Kan Liang
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Andrew Morton
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: acme@infradead.org
    Cc: eranian@google.com
    Link: http://lkml.kernel.org/r/1431285195-14269-9-git-send-email-kan.liang@intel.com
    Signed-off-by: Ingo Molnar

    Kan Liang
     

06 May, 2015

2 commits

  • Add support for the PERF_RECORD_ITRACE_START event type. This event can
    be used to determine the pid and tid that are running when Instruction
    Tracing starts. Generally that information would come from a
    sched_switch event but, at the start, no sched_switch events may yet
    have been recorded.

    Signed-off-by: Adrian Hunter
    Acked-by: Jiri Olsa
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1430404667-10593-8-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Add support for the PERF_RECORD_AUX event type.

    PERF_RECORD_AUX is a new kernel event that records when new data lands
    in the AUX buffer. Currently it is assumed that AUX data follows the
    same ring buffer conventions used by the perf events buffer, and
    consequently the AUX event is not processed during recording.

    It is processed during session processing so that the information in the
    'flags' member is made available.

    The format of PERF_RECORD_AUX is outlined in the linux/perf_events.h
    header file. The 'flags' are also enumerated.

    Intel PT and Intel BTS use the flag named PERF_AUX_FLAG_TRUNCATED to
    determine if data has been lost because the buffer became full as perf
    was not able to empty it fast enough.

    Signed-off-by: Adrian Hunter
    Acked-by: Jiri Olsa
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1430404667-10593-7-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

29 Apr, 2015

2 commits

  • Errors encountered when decoding an AUX area trace need to be reported
    to the user. However the "user" might be a script or another tool, so
    provide a new user event to capture those errors.

    Signed-off-by: Adrian Hunter
    Acked-by: Jiri Olsa
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1428594864-29309-8-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     
  • Add two user events for AUX area tracing.

    PERF_RECORD_AUXTRACE_INFO contains metadata, consisting primarily the
    type of the AUX area tracing data plus some amount of
    architecture-specific information. There should be only one
    PERF_RECORD_AUXTRACE_INFO event.

    PERF_RECORD_AUXTRACE identifies AUX area tracing data copied from the
    mmapped AUX area tracing region. The actual data is not part of the
    event but immediately follows it.

    Signed-off-by: Adrian Hunter
    Acked-by: Jiri Olsa
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1428594864-29309-4-git-send-email-adrian.hunter@intel.com
    [ s/MIN/min/g and use cast to fix up wrt -Werror=sign-compare till we adopt min_t() ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

12 Mar, 2015

1 commit


29 Oct, 2014

1 commit

  • 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: Adrian Hunter
    Acked-by: Jiri Olsa
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1414417770-18602-2-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

12 Aug, 2014

1 commit

  • The time ordering is generic for all kinds of events, so using generic
    name 'ordered_events' for ordered_samples bool in perf_tool struct.

    No functional change was intended.

    Signed-off-by: Jiri Olsa
    Acked-by: David Ahern
    Cc: Corey Ashford
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Jean Pihet
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/n/tip-07mrqzcuhsks9wfmxrzsvemz@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     

11 Sep, 2013

1 commit

  • 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: Stephane Eranian
    Cc: Andi Kleen
    Cc: David Ahern
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1377079825-19057-3-git-send-email-eranian@google.com
    [ Cope with 314add6 "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: Arnaldo Carvalho de Melo

    Stephane Eranian
     

16 Jul, 2013

1 commit

  • Removing event types framework completely. The only remainder (apart
    from few comments) is following enum:

    enum perf_user_event_type {
    ...
    PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */
    ...
    }

    It's kept as deprecated, resulting in error when processed in
    perf_session__process_user_event function.

    Signed-off-by: Jiri Olsa
    Acked-by: Namhyung Kim
    Cc: Corey Ashford
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1373556513-3000-6-git-send-email-jolsa@redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     

13 Jul, 2013

1 commit

  • The 'inject' command expects to get a reference to 'struct perf_inject'
    from its 'tool' member. For that to work, 'tool' needs to be a
    parameter of all tool callbacks. Make it so.

    Signed-off-by: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Mike Galbraith
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/r/1372944040-32690-3-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Adrian Hunter
     

29 Nov, 2011

1 commit

  • Since we already ask for PERF_SAMPLE_ID and use it to quickly find the
    associated evsel, add handler func + data to struct perf_evsel to avoid
    using chains of if(strcmp(event_name)) and also to avoid all the linear
    list searches via trace_event_find.

    To demonstrate the technique convert 'perf sched' to it:

    # perf sched record sleep 5m

    And then:

    Performance counter stats for '/tmp/oldperf sched lat':

    646.929438 task-clock # 0.999 CPUs utilized
    9 context-switches # 0.000 M/sec
    0 CPU-migrations # 0.000 M/sec
    20,901 page-faults # 0.032 M/sec
    1,290,144,450 cycles # 1.994 GHz
    stalled-cycles-frontend
    stalled-cycles-backend
    1,606,158,439 instructions # 1.24 insns per cycle
    339,088,395 branches # 524.151 M/sec
    4,550,735 branch-misses # 1.34% of all branches

    0.647524759 seconds time elapsed

    Versus:

    Performance counter stats for 'perf sched lat':

    473.564691 task-clock # 0.999 CPUs utilized
    9 context-switches # 0.000 M/sec
    0 CPU-migrations # 0.000 M/sec
    20,903 page-faults # 0.044 M/sec
    944,367,984 cycles # 1.994 GHz
    stalled-cycles-frontend
    stalled-cycles-backend
    1,442,385,571 instructions # 1.53 insns per cycle
    308,383,106 branches # 651.195 M/sec
    4,481,784 branch-misses # 1.45% of all branches

    0.474215751 seconds time elapsed

    [root@emilia ~]#

    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/n/tip-1kbzpl74lwi6lavpqke2u2p3@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

28 Nov, 2011

1 commit

  • To better reflect that it became the base class for all tools, that must
    be in each tool struct and where common stuff will be put.

    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/n/tip-qgpc4msetqlwr8y2k7537cxe@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo