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.

Dependency Surface

Detected Declarations

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

Implementation Notes