2016-06-25 04:41:25 +08:00
|
|
|
perf.data format
|
|
|
|
|
|
|
|
Uptodate as of v4.7
|
|
|
|
|
|
|
|
This document describes the on-disk perf.data format, generated by perf record
|
|
|
|
or perf inject and consumed by the other perf tools.
|
|
|
|
|
|
|
|
On a high level perf.data contains the events generated by the PMUs, plus metadata.
|
|
|
|
|
|
|
|
All fields are in native-endian of the machine that generated the perf.data.
|
|
|
|
|
|
|
|
When perf is writing to a pipe it uses a special version of the file
|
|
|
|
format that does not rely on seeking to adjust data offsets. This
|
2017-04-11 04:14:28 +08:00
|
|
|
format is described in "Pipe-mode data" section. The pipe data version can be
|
|
|
|
augmented with additional events using perf inject.
|
2016-06-25 04:41:25 +08:00
|
|
|
|
|
|
|
The file starts with a perf_header:
|
|
|
|
|
|
|
|
struct perf_header {
|
|
|
|
char magic[8]; /* PERFILE2 */
|
|
|
|
uint64_t size; /* size of the header */
|
|
|
|
uint64_t attr_size; /* size of an attribute in attrs */
|
|
|
|
struct perf_file_section attrs;
|
|
|
|
struct perf_file_section data;
|
|
|
|
struct perf_file_section event_types;
|
|
|
|
uint64_t flags;
|
|
|
|
uint64_t flags1[3];
|
|
|
|
};
|
|
|
|
|
|
|
|
The magic number identifies the perf file and the version. Current perf versions
|
|
|
|
use PERFILE2. Old perf versions generated a version 1 format (PERFFILE). Version 1
|
|
|
|
is not described here. The magic number also identifies the endian. When the
|
|
|
|
magic value is 64bit byte swapped compared the file is in non-native
|
|
|
|
endian.
|
|
|
|
|
|
|
|
A perf_file_section contains a pointer to another section of the perf file.
|
|
|
|
The header contains three such pointers: for attributes, data and event types.
|
|
|
|
|
|
|
|
struct perf_file_section {
|
|
|
|
uint64_t offset; /* offset from start of file */
|
|
|
|
uint64_t size; /* size of the section */
|
|
|
|
};
|
|
|
|
|
|
|
|
Flags section:
|
|
|
|
|
2019-02-19 23:45:15 +08:00
|
|
|
For each of the optional features a perf_file_section it placed after the data
|
|
|
|
section if the feature bit is set in the perf_header flags bitset. The
|
|
|
|
respective perf_file_section points to the data of the additional header and
|
|
|
|
defines its size.
|
2016-06-25 04:41:25 +08:00
|
|
|
|
|
|
|
Some headers consist of strings, which are defined like this:
|
|
|
|
|
|
|
|
struct perf_header_string {
|
|
|
|
uint32_t len;
|
|
|
|
char string[len]; /* zero terminated */
|
|
|
|
};
|
|
|
|
|
|
|
|
Some headers consist of a sequence of strings, which start with a
|
|
|
|
|
|
|
|
struct perf_header_string_list {
|
|
|
|
uint32_t nr;
|
|
|
|
struct perf_header_string strings[nr]; /* variable length records */
|
|
|
|
};
|
|
|
|
|
|
|
|
The bits are the flags bits in a 256 bit bitmap starting with
|
|
|
|
flags. These define the valid bits:
|
|
|
|
|
|
|
|
HEADER_RESERVED = 0, /* always cleared */
|
|
|
|
HEADER_FIRST_FEATURE = 1,
|
|
|
|
HEADER_TRACING_DATA = 1,
|
|
|
|
|
|
|
|
Describe me.
|
|
|
|
|
|
|
|
HEADER_BUILD_ID = 2,
|
|
|
|
|
|
|
|
The header consists of an sequence of build_id_event. The size of each record
|
|
|
|
is defined by header.size (see perf_event.h). Each event defines a ELF build id
|
|
|
|
for a executable file name for a pid. An ELF build id is a unique identifier
|
|
|
|
assigned by the linker to an executable.
|
|
|
|
|
|
|
|
struct build_id_event {
|
|
|
|
struct perf_event_header header;
|
|
|
|
pid_t pid;
|
|
|
|
uint8_t build_id[24];
|
|
|
|
char filename[header.size - offsetof(struct build_id_event, filename)];
|
|
|
|
};
|
|
|
|
|
|
|
|
HEADER_HOSTNAME = 3,
|
|
|
|
|
|
|
|
A perf_header_string with the hostname where the data was collected
|
|
|
|
(uname -n)
|
|
|
|
|
|
|
|
HEADER_OSRELEASE = 4,
|
|
|
|
|
|
|
|
A perf_header_string with the os release where the data was collected
|
|
|
|
(uname -r)
|
|
|
|
|
|
|
|
HEADER_VERSION = 5,
|
|
|
|
|
|
|
|
A perf_header_string with the perf user tool version where the
|
|
|
|
data was collected. This is the same as the version of the source tree
|
|
|
|
the perf tool was built from.
|
|
|
|
|
|
|
|
HEADER_ARCH = 6,
|
|
|
|
|
|
|
|
A perf_header_string with the CPU architecture (uname -m)
|
|
|
|
|
|
|
|
HEADER_NRCPUS = 7,
|
|
|
|
|
|
|
|
A structure defining the number of CPUs.
|
|
|
|
|
|
|
|
struct nr_cpus {
|
|
|
|
uint32_t nr_cpus_available; /* CPUs not yet onlined */
|
2018-05-26 03:37:36 +08:00
|
|
|
uint32_t nr_cpus_online;
|
2016-06-25 04:41:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
HEADER_CPUDESC = 8,
|
|
|
|
|
|
|
|
A perf_header_string with description of the CPU. On x86 this is the model name
|
|
|
|
in /proc/cpuinfo
|
|
|
|
|
|
|
|
HEADER_CPUID = 9,
|
|
|
|
|
|
|
|
A perf_header_string with the exact CPU type. On x86 this is
|
|
|
|
vendor,family,model,stepping. For example: GenuineIntel,6,69,1
|
|
|
|
|
|
|
|
HEADER_TOTAL_MEM = 10,
|
|
|
|
|
|
|
|
An uint64_t with the total memory in bytes.
|
|
|
|
|
|
|
|
HEADER_CMDLINE = 11,
|
|
|
|
|
2019-02-19 23:45:14 +08:00
|
|
|
A perf_header_string_list with the perf arg-vector used to collect the data.
|
2016-06-25 04:41:25 +08:00
|
|
|
|
|
|
|
HEADER_EVENT_DESC = 12,
|
|
|
|
|
|
|
|
Another description of the perf_event_attrs, more detailed than header.attrs
|
|
|
|
including IDs and names. See perf_event.h or the man page for a description
|
|
|
|
of a struct perf_event_attr.
|
|
|
|
|
|
|
|
struct {
|
|
|
|
uint32_t nr; /* number of events */
|
|
|
|
uint32_t attr_size; /* size of each perf_event_attr */
|
|
|
|
struct {
|
|
|
|
struct perf_event_attr attr; /* size of attr_size */
|
|
|
|
uint32_t nr_ids;
|
|
|
|
struct perf_header_string event_string;
|
|
|
|
uint64_t ids[nr_ids];
|
|
|
|
} events[nr]; /* Variable length records */
|
|
|
|
};
|
|
|
|
|
|
|
|
HEADER_CPU_TOPOLOGY = 13,
|
|
|
|
|
|
|
|
String lists defining the core and CPU threads topology.
|
2018-05-28 15:44:33 +08:00
|
|
|
The string lists are followed by a variable length array
|
|
|
|
which contains core_id and socket_id of each cpu.
|
|
|
|
The number of entries can be determined by the size of the
|
|
|
|
section minus the sizes of both string lists.
|
2016-06-25 04:41:25 +08:00
|
|
|
|
|
|
|
struct {
|
|
|
|
struct perf_header_string_list cores; /* Variable length */
|
|
|
|
struct perf_header_string_list threads; /* Variable length */
|
2018-05-28 15:44:33 +08:00
|
|
|
struct {
|
|
|
|
uint32_t core_id;
|
|
|
|
uint32_t socket_id;
|
|
|
|
} cpus[nr]; /* Variable length records */
|
2016-06-25 04:41:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
Example:
|
|
|
|
sibling cores : 0-3
|
|
|
|
sibling threads : 0-1
|
|
|
|
sibling threads : 2-3
|
|
|
|
|
|
|
|
HEADER_NUMA_TOPOLOGY = 14,
|
|
|
|
|
|
|
|
A list of NUMA node descriptions
|
|
|
|
|
|
|
|
struct {
|
|
|
|
uint32_t nr;
|
|
|
|
struct {
|
|
|
|
uint32_t nodenr;
|
|
|
|
uint64_t mem_total;
|
|
|
|
uint64_t mem_free;
|
|
|
|
struct perf_header_string cpus;
|
|
|
|
} nodes[nr]; /* Variable length records */
|
|
|
|
};
|
|
|
|
|
|
|
|
HEADER_BRANCH_STACK = 15,
|
|
|
|
|
|
|
|
Not implemented in perf.
|
|
|
|
|
|
|
|
HEADER_PMU_MAPPINGS = 16,
|
|
|
|
|
|
|
|
A list of PMU structures, defining the different PMUs supported by perf.
|
|
|
|
|
|
|
|
struct {
|
|
|
|
uint32_t nr;
|
|
|
|
struct pmu {
|
|
|
|
uint32_t pmu_type;
|
|
|
|
struct perf_header_string pmu_name;
|
|
|
|
} [nr]; /* Variable length records */
|
|
|
|
};
|
|
|
|
|
|
|
|
HEADER_GROUP_DESC = 17,
|
|
|
|
|
|
|
|
Description of counter groups ({...} in perf syntax)
|
|
|
|
|
|
|
|
struct {
|
|
|
|
uint32_t nr;
|
|
|
|
struct {
|
|
|
|
struct perf_header_string string;
|
|
|
|
uint32_t leader_idx;
|
|
|
|
uint32_t nr_members;
|
|
|
|
} [nr]; /* Variable length records */
|
|
|
|
};
|
|
|
|
|
|
|
|
HEADER_AUXTRACE = 18,
|
|
|
|
|
|
|
|
Define additional auxtrace areas in the perf.data. auxtrace is used to store
|
|
|
|
undecoded hardware tracing information, such as Intel Processor Trace data.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct auxtrace_index_entry - indexes a AUX area tracing event within a
|
|
|
|
* perf.data file.
|
|
|
|
* @file_offset: offset within the perf.data file
|
|
|
|
* @sz: size of the event
|
|
|
|
*/
|
|
|
|
struct auxtrace_index_entry {
|
|
|
|
u64 file_offset;
|
|
|
|
u64 sz;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PERF_AUXTRACE_INDEX_ENTRY_COUNT 256
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct auxtrace_index - index of AUX area tracing events within a perf.data
|
|
|
|
* file.
|
|
|
|
* @list: linking a number of arrays of entries
|
|
|
|
* @nr: number of entries
|
|
|
|
* @entries: array of entries
|
|
|
|
*/
|
|
|
|
struct auxtrace_index {
|
|
|
|
struct list_head list;
|
|
|
|
size_t nr;
|
|
|
|
struct auxtrace_index_entry entries[PERF_AUXTRACE_INDEX_ENTRY_COUNT];
|
|
|
|
};
|
|
|
|
|
2017-11-09 22:55:24 +08:00
|
|
|
HEADER_STAT = 19,
|
|
|
|
|
|
|
|
This is merely a flag signifying that the data section contains data
|
|
|
|
recorded from perf stat record.
|
|
|
|
|
|
|
|
HEADER_CACHE = 20,
|
|
|
|
|
|
|
|
Description of the cache hierarchy. Based on the Linux sysfs format
|
|
|
|
in /sys/devices/system/cpu/cpu*/cache/
|
|
|
|
|
|
|
|
u32 version Currently always 1
|
|
|
|
u32 number_of_cache_levels
|
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 level;
|
|
|
|
u32 line_size;
|
|
|
|
u32 sets;
|
|
|
|
u32 ways;
|
|
|
|
struct perf_header_string type;
|
|
|
|
struct perf_header_string size;
|
|
|
|
struct perf_header_string map;
|
|
|
|
}[number_of_cache_levels];
|
|
|
|
|
perf header: Add infrastructure to record first and last sample time
perf report/script/... have a --time option to limit the time range of
output. That's very useful to slice large traces, e.g. when processing
the output of perf script for some analysis.
But right now --time only supports absolute time. Also there is no fast
way to get the start/end times of a given trace except for looking at
it. This makes it hard to e.g. only decode the first half of the trace,
which is useful for parallelization of scripts
Another problem is that perf records are variable size and there is no
synchronization mechanism. So the only way to find the last sample
reliably would be to walk all samples. But we want to avoid that in perf
report/... because it is already quite expensive. That is why storing
the first sample time and last sample time in perf record is better.
This patch creates a new header feature type HEADER_SAMPLE_TIME and
related ops. Save the first sample time and the last sample time to the
feature section in perf file header. That will be done when, for
instance, processing build-ids, where we already have to process all
samples to create the build-id table, take advantage of that to further
amortize that processing by storing HEADER_SAMPLE_TIME to make 'perf
report/script' faster when using --time.
Committer testing:
After this patch is applied the header is written with zeroes, we need
the next patch, for "perf record" to actually write the timestamps:
# perf report -D | grep PERF_RECORD_SAMPLE\(
22501155244406 0x44f0 [0x28]: PERF_RECORD_SAMPLE(IP, 0x4001): 25016/25016: 0xffffffffa21be8c5 period: 1 addr: 0
<SNIP>
22501155793625 0x4a30 [0x28]: PERF_RECORD_SAMPLE(IP, 0x4001): 25016/25016: 0xffffffffa21ffd50 period: 2828043 addr: 0
# perf report --header | grep "time of "
# time of first sample : 0.000000
# time of last sample : 0.000000
#
Changelog:
v7: 1. Rebase to latest perf/core branch.
2. Add following clarification in patch description according to
Arnaldo's suggestion.
"That will be done when, for instance, processing build-ids,
where we already have to process all samples to create the
build-id table, take advantage of that to further amortize
that processing by storing HEADER_SAMPLE_TIME to make
'perf report/script' faster when using --time."
v4: Use perf script time style for timestamp printing. Also add with
the printing of sample duration.
v3: Remove the definitions of first_sample_time/last_sample_time from
perf_session. Just define them in perf_evlist
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1512738826-2628-2-git-send-email-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-12-08 21:13:41 +08:00
|
|
|
HEADER_SAMPLE_TIME = 21,
|
|
|
|
|
|
|
|
Two uint64_t for the time of first sample and the time of last sample.
|
|
|
|
|
2019-05-30 02:35:03 +08:00
|
|
|
HEADER_SAMPLE_TOPOLOGY = 22,
|
|
|
|
|
|
|
|
Physical memory map and its node assignments.
|
|
|
|
|
|
|
|
The format of data in MEM_TOPOLOGY is as follows:
|
|
|
|
|
|
|
|
0 - version | for future changes
|
|
|
|
8 - block_size_bytes | /sys/devices/system/memory/block_size_bytes
|
|
|
|
16 - count | number of nodes
|
|
|
|
|
|
|
|
For each node we store map of physical indexes:
|
|
|
|
|
|
|
|
32 - node id | node index
|
|
|
|
40 - size | size of bitmap
|
|
|
|
48 - bitmap | bitmap of memory indexes that belongs to node
|
|
|
|
| /sys/devices/system/node/node<NODE>/memory<INDEX>
|
|
|
|
|
|
|
|
The MEM_TOPOLOGY can be displayed with following command:
|
|
|
|
|
|
|
|
$ perf report --header-only -I
|
|
|
|
...
|
|
|
|
# memory nodes (nr 1, block size 0x8000000):
|
|
|
|
# 0 [7G]: 0-23,32-69
|
|
|
|
|
2019-05-30 02:43:51 +08:00
|
|
|
HEADER_CLOCKID = 23,
|
|
|
|
|
|
|
|
One uint64_t for the clockid frequency, specified, for instance, via 'perf
|
|
|
|
record -k' (see clock_gettime()), to enable timestamps derived metrics
|
|
|
|
conversion into wall clock time on the reporting stage.
|
|
|
|
|
2019-05-21 14:44:06 +08:00
|
|
|
HEADER_BPF_PROG_INFO = 25,
|
|
|
|
|
|
|
|
struct bpf_prog_info_linear, which contains detailed information about
|
|
|
|
a BPF program, including type, id, tag, jited/xlated instructions, etc.
|
|
|
|
|
|
|
|
HEADER_BPF_BTF = 26,
|
|
|
|
|
|
|
|
Contains BPF Type Format (BTF). For more information about BTF, please
|
|
|
|
refer to Documentation/bpf/btf.rst.
|
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 id;
|
|
|
|
u32 data_size;
|
|
|
|
char data[];
|
|
|
|
};
|
|
|
|
|
2019-03-19 01:41:33 +08:00
|
|
|
HEADER_COMPRESSED = 27,
|
|
|
|
|
|
|
|
struct {
|
|
|
|
u32 version;
|
|
|
|
u32 type;
|
|
|
|
u32 level;
|
|
|
|
u32 ratio;
|
|
|
|
u32 mmap_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
Indicates that trace contains records of PERF_RECORD_COMPRESSED type
|
|
|
|
that have perf_events records in compressed form.
|
|
|
|
|
2016-06-25 04:41:25 +08:00
|
|
|
other bits are reserved and should ignored for now
|
|
|
|
HEADER_FEAT_BITS = 256,
|
|
|
|
|
|
|
|
Attributes
|
|
|
|
|
|
|
|
This is an array of perf_event_attrs, each attr_size bytes long, which defines
|
|
|
|
each event collected. See perf_event.h or the man page for a detailed
|
|
|
|
description.
|
|
|
|
|
|
|
|
Data
|
|
|
|
|
|
|
|
This section is the bulk of the file. It consist of a stream of perf_events
|
|
|
|
describing events. This matches the format generated by the kernel.
|
|
|
|
See perf_event.h or the manpage for a detailed description.
|
|
|
|
|
|
|
|
Some notes on parsing:
|
|
|
|
|
|
|
|
Ordering
|
|
|
|
|
|
|
|
The events are not necessarily in time stamp order, as they can be
|
|
|
|
collected in parallel on different CPUs. If the events should be
|
|
|
|
processed in time order they need to be sorted first. It is possible
|
|
|
|
to only do a partial sort using the FINISHED_ROUND event header (see
|
|
|
|
below). perf record guarantees that there is no reordering over a
|
|
|
|
FINISHED_ROUND.
|
|
|
|
|
|
|
|
ID vs IDENTIFIER
|
|
|
|
|
|
|
|
When the event stream contains multiple events each event is identified
|
|
|
|
by an ID. This can be either through the PERF_SAMPLE_ID or the
|
|
|
|
PERF_SAMPLE_IDENTIFIER header. The PERF_SAMPLE_IDENTIFIER header is
|
|
|
|
at a fixed offset from the event header, which allows reliable
|
2017-05-03 20:13:50 +08:00
|
|
|
parsing of the header. Relying on ID may be ambiguous.
|
2016-06-25 04:41:25 +08:00
|
|
|
IDENTIFIER is only supported by newer Linux kernels.
|
|
|
|
|
|
|
|
Perf record specific events:
|
|
|
|
|
|
|
|
In addition to the kernel generated event types perf record adds its
|
|
|
|
own event types (in addition it also synthesizes some kernel events,
|
|
|
|
for example MMAP events)
|
|
|
|
|
|
|
|
PERF_RECORD_USER_TYPE_START = 64,
|
|
|
|
PERF_RECORD_HEADER_ATTR = 64,
|
|
|
|
|
|
|
|
struct attr_event {
|
|
|
|
struct perf_event_header header;
|
|
|
|
struct perf_event_attr attr;
|
|
|
|
uint64_t id[];
|
|
|
|
};
|
|
|
|
|
2017-05-03 20:13:50 +08:00
|
|
|
PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */
|
2016-06-25 04:41:25 +08:00
|
|
|
|
|
|
|
#define MAX_EVENT_NAME 64
|
|
|
|
|
|
|
|
struct perf_trace_event_type {
|
|
|
|
uint64_t event_id;
|
|
|
|
char name[MAX_EVENT_NAME];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct event_type_event {
|
|
|
|
struct perf_event_header header;
|
|
|
|
struct perf_trace_event_type event_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
PERF_RECORD_HEADER_TRACING_DATA = 66,
|
|
|
|
|
|
|
|
Describe me
|
|
|
|
|
|
|
|
struct tracing_data_event {
|
|
|
|
struct perf_event_header header;
|
|
|
|
uint32_t size;
|
|
|
|
};
|
|
|
|
|
|
|
|
PERF_RECORD_HEADER_BUILD_ID = 67,
|
|
|
|
|
|
|
|
Define a ELF build ID for a referenced executable.
|
|
|
|
|
|
|
|
struct build_id_event; /* See above */
|
|
|
|
|
|
|
|
PERF_RECORD_FINISHED_ROUND = 68,
|
|
|
|
|
|
|
|
No event reordering over this header. No payload.
|
|
|
|
|
|
|
|
PERF_RECORD_ID_INDEX = 69,
|
|
|
|
|
|
|
|
Map event ids to CPUs and TIDs.
|
|
|
|
|
|
|
|
struct id_index_entry {
|
|
|
|
uint64_t id;
|
|
|
|
uint64_t idx;
|
|
|
|
uint64_t cpu;
|
|
|
|
uint64_t tid;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct id_index_event {
|
|
|
|
struct perf_event_header header;
|
|
|
|
uint64_t nr;
|
|
|
|
struct id_index_entry entries[nr];
|
|
|
|
};
|
|
|
|
|
|
|
|
PERF_RECORD_AUXTRACE_INFO = 70,
|
|
|
|
|
|
|
|
Auxtrace type specific information. Describe me
|
|
|
|
|
|
|
|
struct auxtrace_info_event {
|
|
|
|
struct perf_event_header header;
|
|
|
|
uint32_t type;
|
|
|
|
uint32_t reserved__; /* For alignment */
|
|
|
|
uint64_t priv[];
|
|
|
|
};
|
|
|
|
|
|
|
|
PERF_RECORD_AUXTRACE = 71,
|
|
|
|
|
|
|
|
Defines auxtrace data. Followed by the actual data. The contents of
|
|
|
|
the auxtrace data is dependent on the event and the CPU. For example
|
|
|
|
for Intel Processor Trace it contains Processor Trace data generated
|
|
|
|
by the CPU.
|
|
|
|
|
|
|
|
struct auxtrace_event {
|
|
|
|
struct perf_event_header header;
|
|
|
|
uint64_t size;
|
|
|
|
uint64_t offset;
|
|
|
|
uint64_t reference;
|
|
|
|
uint32_t idx;
|
|
|
|
uint32_t tid;
|
|
|
|
uint32_t cpu;
|
|
|
|
uint32_t reserved__; /* For alignment */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct aux_event {
|
|
|
|
struct perf_event_header header;
|
|
|
|
uint64_t aux_offset;
|
|
|
|
uint64_t aux_size;
|
|
|
|
uint64_t flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
PERF_RECORD_AUXTRACE_ERROR = 72,
|
|
|
|
|
|
|
|
Describes an error in hardware tracing
|
|
|
|
|
|
|
|
enum auxtrace_error_type {
|
|
|
|
PERF_AUXTRACE_ERROR_ITRACE = 1,
|
|
|
|
PERF_AUXTRACE_ERROR_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_AUXTRACE_ERROR_MSG 64
|
|
|
|
|
|
|
|
struct auxtrace_error_event {
|
|
|
|
struct perf_event_header header;
|
|
|
|
uint32_t type;
|
|
|
|
uint32_t code;
|
|
|
|
uint32_t cpu;
|
|
|
|
uint32_t pid;
|
|
|
|
uint32_t tid;
|
|
|
|
uint32_t reserved__; /* For alignment */
|
|
|
|
uint64_t ip;
|
|
|
|
char msg[MAX_AUXTRACE_ERROR_MSG];
|
|
|
|
};
|
|
|
|
|
perf tools: Add feature header record to pipe-mode
Add header record types to pipe-mode, reusing the functions
used in file-mode and leveraging the new struct feat_fd.
For alignment, check that synthesized events don't exceed
pagesize.
Add the perf_event__synthesize_feature event call back to
process the new header records.
Before this patch:
$ perf record -o - -e cycles sleep 1 | perf report --stdio --header
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]
...
After this patch:
$ perf record -o - -e cycles sleep 1 | perf report --stdio --header
# ========
# captured on: Mon May 22 16:33:43 2017
# ========
#
# hostname : my_hostname
# os release : 4.11.0-dbx-up_perf
# perf version : 4.11.rc6.g6277c80
# arch : x86_64
# nrcpus online : 72
# nrcpus avail : 72
# cpudesc : Intel(R) Xeon(R) CPU E5-2696 v3 @ 2.30GHz
# cpuid : GenuineIntel,6,63,2
# total memory : 263457192 kB
# cmdline : /root/perf record -o - -e cycles -c 100000 sleep 1
# HEADER_CPU_TOPOLOGY info available, use -I to display
# HEADER_NUMA_TOPOLOGY info available, use -I to display
# pmu mappings: intel_bts = 6, uncore_imc_4 = 22, uncore_sbox_1 = 47, uncore_cbox_5 = 33, uncore_ha_0 = 16, uncore_cbox
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]
...
Support added for the subcommands: report, inject, annotate and script.
Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
Acked-by: David Ahern <dsahern@gmail.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Turner <pjt@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Simon Que <sque@chromium.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20170718042549.145161-16-davidcc@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-07-18 12:25:48 +08:00
|
|
|
PERF_RECORD_HEADER_FEATURE = 80,
|
|
|
|
|
|
|
|
Describes a header feature. These are records used in pipe-mode that
|
|
|
|
contain information that otherwise would be in perf.data file's header.
|
|
|
|
|
2019-03-19 01:41:33 +08:00
|
|
|
PERF_RECORD_COMPRESSED = 81,
|
|
|
|
|
|
|
|
struct compressed_event {
|
|
|
|
struct perf_event_header header;
|
|
|
|
char data[];
|
|
|
|
};
|
|
|
|
|
|
|
|
The header is followed by compressed data frame that can be decompressed
|
|
|
|
into array of perf trace records. The size of the entire compressed event
|
|
|
|
record including the header is limited by the max value of header.size.
|
|
|
|
|
2016-06-25 04:41:25 +08:00
|
|
|
Event types
|
|
|
|
|
|
|
|
Define the event attributes with their IDs.
|
|
|
|
|
|
|
|
An array bound by the perf_file_section size.
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct perf_event_attr attr; /* Size defined by header.attr_size */
|
|
|
|
struct perf_file_section ids;
|
|
|
|
}
|
|
|
|
|
|
|
|
ids points to a array of uint64_t defining the ids for event attr attr.
|
|
|
|
|
2017-04-11 04:14:28 +08:00
|
|
|
Pipe-mode data
|
|
|
|
|
|
|
|
Pipe-mode avoid seeks in the file by removing the perf_file_section and flags
|
|
|
|
from the struct perf_header. The trimmed header is:
|
|
|
|
|
|
|
|
struct perf_pipe_file_header {
|
|
|
|
u64 magic;
|
|
|
|
u64 size;
|
|
|
|
};
|
|
|
|
|
|
|
|
The information about attrs, data, and event_types is instead in the
|
perf tools: Add feature header record to pipe-mode
Add header record types to pipe-mode, reusing the functions
used in file-mode and leveraging the new struct feat_fd.
For alignment, check that synthesized events don't exceed
pagesize.
Add the perf_event__synthesize_feature event call back to
process the new header records.
Before this patch:
$ perf record -o - -e cycles sleep 1 | perf report --stdio --header
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]
...
After this patch:
$ perf record -o - -e cycles sleep 1 | perf report --stdio --header
# ========
# captured on: Mon May 22 16:33:43 2017
# ========
#
# hostname : my_hostname
# os release : 4.11.0-dbx-up_perf
# perf version : 4.11.rc6.g6277c80
# arch : x86_64
# nrcpus online : 72
# nrcpus avail : 72
# cpudesc : Intel(R) Xeon(R) CPU E5-2696 v3 @ 2.30GHz
# cpuid : GenuineIntel,6,63,2
# total memory : 263457192 kB
# cmdline : /root/perf record -o - -e cycles -c 100000 sleep 1
# HEADER_CPU_TOPOLOGY info available, use -I to display
# HEADER_NUMA_TOPOLOGY info available, use -I to display
# pmu mappings: intel_bts = 6, uncore_imc_4 = 22, uncore_sbox_1 = 47, uncore_cbox_5 = 33, uncore_ha_0 = 16, uncore_cbox
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.000 MB - ]
...
Support added for the subcommands: report, inject, annotate and script.
Signed-off-by: David Carrillo-Cisneros <davidcc@google.com>
Acked-by: David Ahern <dsahern@gmail.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Turner <pjt@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Simon Que <sque@chromium.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20170718042549.145161-16-davidcc@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-07-18 12:25:48 +08:00
|
|
|
synthesized events PERF_RECORD_ATTR, PERF_RECORD_HEADER_TRACING_DATA,
|
|
|
|
PERF_RECORD_HEADER_EVENT_TYPE, and PERF_RECORD_HEADER_FEATURE
|
|
|
|
that are generated by perf record in pipe-mode.
|
2017-04-11 04:14:28 +08:00
|
|
|
|
|
|
|
|
2016-06-25 04:41:25 +08:00
|
|
|
References:
|
|
|
|
|
|
|
|
include/uapi/linux/perf_event.h
|
|
|
|
|
|
|
|
This is the canonical description of the kernel generated perf_events
|
|
|
|
and the perf_event_attrs.
|
|
|
|
|
|
|
|
perf_events manpage
|
|
|
|
|
|
|
|
A manpage describing perf_event and perf_event_attr is here:
|
|
|
|
http://web.eece.maine.edu/~vweaver/projects/perf_events/programming.html
|
|
|
|
This tends to be slightly behind the kernel include, but has better
|
|
|
|
descriptions. An (typically older) version of the man page may be
|
|
|
|
included with the standard Linux man pages, available with "man
|
|
|
|
perf_events"
|
|
|
|
|
|
|
|
pmu-tools
|
|
|
|
|
|
|
|
https://github.com/andikleen/pmu-tools/tree/master/parser
|
|
|
|
|
|
|
|
A definition of the perf.data format in python "construct" format is available
|
|
|
|
in pmu-tools parser. This allows to read perf.data from python and dump it.
|
|
|
|
|
|
|
|
quipper
|
|
|
|
|
|
|
|
The quipper C++ parser is available at
|
2018-03-08 15:59:45 +08:00
|
|
|
http://github.com/google/perf_data_converter/tree/master/src/quipper
|
2016-09-29 02:37:53 +08:00
|
|
|
|