tools/perf/Documentation/perf.data-file-format.txt
Source file repositories/reference/linux-study-clean/tools/perf/Documentation/perf.data-file-format.txt
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/Documentation/perf.data-file-format.txt- Extension
.txt- Size
- 18429 bytes
- Lines
- 724
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
struct perf_headerstruct perf_file_sectionstruct perf_header_stringstruct perf_header_string_liststruct build_id_eventstruct nr_cpusstruct pmustruct auxtrace_index_entrystruct auxtrace_indexstruct memory_nodestruct bitmapstruct perf_bpilstruct domain_infostruct cpu_domain_infostruct attr_eventstruct perf_trace_event_typestruct event_type_eventstruct tracing_data_eventstruct build_id_eventstruct id_index_entrystruct id_index_eventstruct auxtrace_info_eventstruct auxtrace_eventstruct aux_eventstruct auxtrace_error_eventstruct compressed_eventstruct perf_record_compressed2struct perf_pipe_file_headerenum auxtrace_error_type
Annotated Snippet
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:
For each of the optional features a perf_file_section is 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.
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,
Annotation
- Detected declarations: `struct perf_header`, `struct perf_file_section`, `struct perf_header_string`, `struct perf_header_string_list`, `struct build_id_event`, `struct nr_cpus`, `struct pmu`, `struct auxtrace_index_entry`, `struct auxtrace_index`, `struct memory_node`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.