^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) perf.data format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) Uptodate as of v4.7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) This document describes the on-disk perf.data format, generated by perf record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) or perf inject and consumed by the other perf tools.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) On a high level perf.data contains the events generated by the PMUs, plus metadata.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) All fields are in native-endian of the machine that generated the perf.data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) When perf is writing to a pipe it uses a special version of the file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) format that does not rely on seeking to adjust data offsets. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) format is described in "Pipe-mode data" section. The pipe data version can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) augmented with additional events using perf inject.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) The file starts with a perf_header:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct perf_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) char magic[8]; /* PERFILE2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) uint64_t size; /* size of the header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) uint64_t attr_size; /* size of an attribute in attrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct perf_file_section attrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct perf_file_section data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct perf_file_section event_types;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) uint64_t flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) uint64_t flags1[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) The magic number identifies the perf file and the version. Current perf versions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) use PERFILE2. Old perf versions generated a version 1 format (PERFFILE). Version 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) is not described here. The magic number also identifies the endian. When the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) magic value is 64bit byte swapped compared the file is in non-native
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) endian.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) A perf_file_section contains a pointer to another section of the perf file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) The header contains three such pointers: for attributes, data and event types.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct perf_file_section {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) uint64_t offset; /* offset from start of file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) uint64_t size; /* size of the section */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) Flags section:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) For each of the optional features a perf_file_section it placed after the data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) section if the feature bit is set in the perf_header flags bitset. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) respective perf_file_section points to the data of the additional header and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) defines its size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) Some headers consist of strings, which are defined like this:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct perf_header_string {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) uint32_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) char string[len]; /* zero terminated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) Some headers consist of a sequence of strings, which start with a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct perf_header_string_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) uint32_t nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct perf_header_string strings[nr]; /* variable length records */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) The bits are the flags bits in a 256 bit bitmap starting with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) flags. These define the valid bits:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) HEADER_RESERVED = 0, /* always cleared */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) HEADER_FIRST_FEATURE = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) HEADER_TRACING_DATA = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) Describe me.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) HEADER_BUILD_ID = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) The header consists of an sequence of build_id_event. The size of each record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) is defined by header.size (see perf_event.h). Each event defines a ELF build id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) for a executable file name for a pid. An ELF build id is a unique identifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) assigned by the linker to an executable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) struct build_id_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) struct perf_event_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) pid_t pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) uint8_t build_id[24];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) char filename[header.size - offsetof(struct build_id_event, filename)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) HEADER_HOSTNAME = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) A perf_header_string with the hostname where the data was collected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) (uname -n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) HEADER_OSRELEASE = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) A perf_header_string with the os release where the data was collected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) (uname -r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) HEADER_VERSION = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) A perf_header_string with the perf user tool version where the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) data was collected. This is the same as the version of the source tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) the perf tool was built from.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) HEADER_ARCH = 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) A perf_header_string with the CPU architecture (uname -m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) HEADER_NRCPUS = 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) A structure defining the number of CPUs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct nr_cpus {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) uint32_t nr_cpus_available; /* CPUs not yet onlined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) uint32_t nr_cpus_online;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) HEADER_CPUDESC = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) A perf_header_string with description of the CPU. On x86 this is the model name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) in /proc/cpuinfo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) HEADER_CPUID = 9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) A perf_header_string with the exact CPU type. On x86 this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) vendor,family,model,stepping. For example: GenuineIntel,6,69,1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) HEADER_TOTAL_MEM = 10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) An uint64_t with the total memory in kilobytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) HEADER_CMDLINE = 11,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) A perf_header_string_list with the perf arg-vector used to collect the data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) HEADER_EVENT_DESC = 12,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) Another description of the perf_event_attrs, more detailed than header.attrs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) including IDs and names. See perf_event.h or the man page for a description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) of a struct perf_event_attr.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) uint32_t nr; /* number of events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) uint32_t attr_size; /* size of each perf_event_attr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct perf_event_attr attr; /* size of attr_size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) uint32_t nr_ids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct perf_header_string event_string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) uint64_t ids[nr_ids];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) } events[nr]; /* Variable length records */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) HEADER_CPU_TOPOLOGY = 13,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * First revision of HEADER_CPU_TOPOLOGY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * See 'struct perf_header_string_list' definition earlier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * in this file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) struct perf_header_string_list cores; /* Variable length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct perf_header_string_list threads; /* Variable length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * Second revision of HEADER_CPU_TOPOLOGY, older tools
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * will not consider what comes next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) uint32_t core_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) uint32_t socket_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) } cpus[nr]; /* Variable length records */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* 'nr' comes from previously processed HEADER_NRCPUS's nr_cpu_avail */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * Third revision of HEADER_CPU_TOPOLOGY, older tools
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * will not consider what comes next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) struct perf_header_string_list dies; /* Variable length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) uint32_t die_id[nr_cpus_avail]; /* from previously processed HEADER_NR_CPUS, VLA */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) Example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) sibling sockets : 0-8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) sibling dies : 0-3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) sibling dies : 4-7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) sibling threads : 0-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) sibling threads : 2-3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) sibling threads : 4-5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) sibling threads : 6-7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) HEADER_NUMA_TOPOLOGY = 14,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) A list of NUMA node descriptions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) uint32_t nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) uint32_t nodenr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) uint64_t mem_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) uint64_t mem_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) struct perf_header_string cpus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) } nodes[nr]; /* Variable length records */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) HEADER_BRANCH_STACK = 15,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) Not implemented in perf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) HEADER_PMU_MAPPINGS = 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) A list of PMU structures, defining the different PMUs supported by perf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) uint32_t nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct pmu {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) uint32_t pmu_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) struct perf_header_string pmu_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) } [nr]; /* Variable length records */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) HEADER_GROUP_DESC = 17,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) Description of counter groups ({...} in perf syntax)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) uint32_t nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct perf_header_string string;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) uint32_t leader_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) uint32_t nr_members;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) } [nr]; /* Variable length records */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) HEADER_AUXTRACE = 18,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) Define additional auxtrace areas in the perf.data. auxtrace is used to store
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) undecoded hardware tracing information, such as Intel Processor Trace data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * struct auxtrace_index_entry - indexes a AUX area tracing event within a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) * perf.data file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * @file_offset: offset within the perf.data file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * @sz: size of the event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) struct auxtrace_index_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) u64 file_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) u64 sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) #define PERF_AUXTRACE_INDEX_ENTRY_COUNT 256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * struct auxtrace_index - index of AUX area tracing events within a perf.data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * @list: linking a number of arrays of entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * @nr: number of entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) * @entries: array of entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct auxtrace_index {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) size_t nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) struct auxtrace_index_entry entries[PERF_AUXTRACE_INDEX_ENTRY_COUNT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) HEADER_STAT = 19,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) This is merely a flag signifying that the data section contains data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) recorded from perf stat record.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) HEADER_CACHE = 20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) Description of the cache hierarchy. Based on the Linux sysfs format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) in /sys/devices/system/cpu/cpu*/cache/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) u32 version Currently always 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) u32 number_of_cache_levels
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) u32 level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) u32 line_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) u32 sets;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) u32 ways;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) struct perf_header_string type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) struct perf_header_string size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) struct perf_header_string map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }[number_of_cache_levels];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) HEADER_SAMPLE_TIME = 21,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) Two uint64_t for the time of first sample and the time of last sample.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) HEADER_SAMPLE_TOPOLOGY = 22,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) Physical memory map and its node assignments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) The format of data in MEM_TOPOLOGY is as follows:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) u64 version; // Currently 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) u64 block_size_bytes; // /sys/devices/system/memory/block_size_bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) u64 count; // number of nodes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) struct memory_node {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) u64 node_id; // node index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) u64 size; // size of bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) struct bitmap {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) /* size of bitmap again */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) u64 bitmapsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) /* bitmap of memory indexes that belongs to node */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) /* /sys/devices/system/node/node<NODE>/memory<INDEX> */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) u64 entries[(bitmapsize/64)+1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) }[count];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) The MEM_TOPOLOGY can be displayed with following command:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) $ perf report --header-only -I
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) # memory nodes (nr 1, block size 0x8000000):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) # 0 [7G]: 0-23,32-69
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) HEADER_CLOCKID = 23,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) One uint64_t for the clockid frequency, specified, for instance, via 'perf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) record -k' (see clock_gettime()), to enable timestamps derived metrics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) conversion into wall clock time on the reporting stage.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) HEADER_DIR_FORMAT = 24,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) The data files layout is described by HEADER_DIR_FORMAT feature. Currently it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) holds only version number (1):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) uint64_t version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) The current version holds only version value (1) means that data files:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) - Follow the 'data.*' name format.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) - Contain raw events data in standard perf format as read from kernel (and need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) to be sorted)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) Future versions are expected to describe different data files layout according
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) to special needs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) HEADER_BPF_PROG_INFO = 25,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) struct bpf_prog_info_linear, which contains detailed information about
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) a BPF program, including type, id, tag, jited/xlated instructions, etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) HEADER_BPF_BTF = 26,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) Contains BPF Type Format (BTF). For more information about BTF, please
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) refer to Documentation/bpf/btf.rst.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) u32 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) u32 data_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) char data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) HEADER_COMPRESSED = 27,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) u32 version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) u32 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) u32 level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) u32 ratio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) u32 mmap_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) Indicates that trace contains records of PERF_RECORD_COMPRESSED type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) that have perf_events records in compressed form.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) HEADER_CPU_PMU_CAPS = 28,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) A list of cpu PMU capabilities. The format of data is as below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) u32 nr_cpu_pmu_caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) char name[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) char value[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) } [nr_cpu_pmu_caps]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) Example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) cpu pmu capabilities: branches=32, max_precise=3, pmu_name=icelake
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) HEADER_CLOCK_DATA = 29,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) Contains clock id and its reference time together with wall clock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) time taken at the 'same time', both values are in nanoseconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) The format of data is as below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) u32 version; /* version = 1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) u32 clockid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) u64 wall_clock_ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) u64 clockid_time_ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) other bits are reserved and should ignored for now
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) HEADER_FEAT_BITS = 256,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) Attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) This is an array of perf_event_attrs, each attr_size bytes long, which defines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) each event collected. See perf_event.h or the man page for a detailed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) description.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) Data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) This section is the bulk of the file. It consist of a stream of perf_events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) describing events. This matches the format generated by the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) See perf_event.h or the manpage for a detailed description.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) Some notes on parsing:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) Ordering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) The events are not necessarily in time stamp order, as they can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) collected in parallel on different CPUs. If the events should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) processed in time order they need to be sorted first. It is possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) to only do a partial sort using the FINISHED_ROUND event header (see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) below). perf record guarantees that there is no reordering over a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) FINISHED_ROUND.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) ID vs IDENTIFIER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) When the event stream contains multiple events each event is identified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) by an ID. This can be either through the PERF_SAMPLE_ID or the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) PERF_SAMPLE_IDENTIFIER header. The PERF_SAMPLE_IDENTIFIER header is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) at a fixed offset from the event header, which allows reliable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) parsing of the header. Relying on ID may be ambiguous.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) IDENTIFIER is only supported by newer Linux kernels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) Perf record specific events:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) In addition to the kernel generated event types perf record adds its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) own event types (in addition it also synthesizes some kernel events,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) for example MMAP events)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) PERF_RECORD_USER_TYPE_START = 64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) PERF_RECORD_HEADER_ATTR = 64,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) struct attr_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) struct perf_event_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) struct perf_event_attr attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) uint64_t id[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) PERF_RECORD_HEADER_EVENT_TYPE = 65, /* deprecated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) #define MAX_EVENT_NAME 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) struct perf_trace_event_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) uint64_t event_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) char name[MAX_EVENT_NAME];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) struct event_type_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) struct perf_event_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) struct perf_trace_event_type event_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) PERF_RECORD_HEADER_TRACING_DATA = 66,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) Describe me
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) struct tracing_data_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) struct perf_event_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) uint32_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) PERF_RECORD_HEADER_BUILD_ID = 67,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) Define a ELF build ID for a referenced executable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) struct build_id_event; /* See above */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) PERF_RECORD_FINISHED_ROUND = 68,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) No event reordering over this header. No payload.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) PERF_RECORD_ID_INDEX = 69,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) Map event ids to CPUs and TIDs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) struct id_index_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) uint64_t id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) uint64_t idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) uint64_t cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) uint64_t tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) struct id_index_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) struct perf_event_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) uint64_t nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) struct id_index_entry entries[nr];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) PERF_RECORD_AUXTRACE_INFO = 70,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) Auxtrace type specific information. Describe me
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) struct auxtrace_info_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) struct perf_event_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) uint32_t type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) uint32_t reserved__; /* For alignment */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) uint64_t priv[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) PERF_RECORD_AUXTRACE = 71,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) Defines auxtrace data. Followed by the actual data. The contents of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) the auxtrace data is dependent on the event and the CPU. For example
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) for Intel Processor Trace it contains Processor Trace data generated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) by the CPU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) struct auxtrace_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) struct perf_event_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) uint64_t size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) uint64_t offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) uint64_t reference;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) uint32_t idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) uint32_t tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) uint32_t cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) uint32_t reserved__; /* For alignment */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) struct aux_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) struct perf_event_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) uint64_t aux_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) uint64_t aux_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) uint64_t flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) PERF_RECORD_AUXTRACE_ERROR = 72,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) Describes an error in hardware tracing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) enum auxtrace_error_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) PERF_AUXTRACE_ERROR_ITRACE = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) PERF_AUXTRACE_ERROR_MAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) #define MAX_AUXTRACE_ERROR_MSG 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) struct auxtrace_error_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) struct perf_event_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) uint32_t type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) uint32_t code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) uint32_t cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) uint32_t pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) uint32_t tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) uint32_t reserved__; /* For alignment */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) uint64_t ip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) char msg[MAX_AUXTRACE_ERROR_MSG];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) PERF_RECORD_HEADER_FEATURE = 80,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) Describes a header feature. These are records used in pipe-mode that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) contain information that otherwise would be in perf.data file's header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) PERF_RECORD_COMPRESSED = 81,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) struct compressed_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) struct perf_event_header header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) char data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) The header is followed by compressed data frame that can be decompressed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) into array of perf trace records. The size of the entire compressed event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) record including the header is limited by the max value of header.size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) Event types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) Define the event attributes with their IDs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) An array bound by the perf_file_section size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) struct perf_event_attr attr; /* Size defined by header.attr_size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) struct perf_file_section ids;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) ids points to a array of uint64_t defining the ids for event attr attr.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) Pipe-mode data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) Pipe-mode avoid seeks in the file by removing the perf_file_section and flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) from the struct perf_header. The trimmed header is:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) struct perf_pipe_file_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) u64 magic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) u64 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) The information about attrs, data, and event_types is instead in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) synthesized events PERF_RECORD_ATTR, PERF_RECORD_HEADER_TRACING_DATA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) PERF_RECORD_HEADER_EVENT_TYPE, and PERF_RECORD_HEADER_FEATURE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) that are generated by perf record in pipe-mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) References:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) include/uapi/linux/perf_event.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) This is the canonical description of the kernel generated perf_events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) and the perf_event_attrs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) perf_events manpage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) A manpage describing perf_event and perf_event_attr is here:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) http://web.eece.maine.edu/~vweaver/projects/perf_events/programming.html
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) This tends to be slightly behind the kernel include, but has better
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) descriptions. An (typically older) version of the man page may be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) included with the standard Linux man pages, available with "man
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) perf_events"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) pmu-tools
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) https://github.com/andikleen/pmu-tools/tree/master/parser
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) A definition of the perf.data format in python "construct" format is available
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) in pmu-tools parser. This allows to read perf.data from python and dump it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) quipper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) The quipper C++ parser is available at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) http://github.com/google/perf_data_converter/tree/master/src/quipper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)