tools/perf/util/header.h
Source file repositories/reference/linux-study-clean/tools/perf/util/header.h
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/header.h- Extension
.h- Size
- 5958 bytes
- Lines
- 226
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
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
linux/stddef.hlinux/perf_event.hsys/types.hstdio.hstdbool.hlinux/bitmap.hlinux/types.henv.hperf/cpumap.h
Detected Declarations
struct evliststruct perf_headerstruct perf_sessionstruct perf_toolstruct perf_file_sectionstruct perf_file_headerstruct perf_pipe_file_headerstruct perf_headerstruct feat_fdstruct perf_header_feature_opsstruct feat_writerstruct feat_copierstruct feat_fdenum perf_header_version
Annotated Snippet
struct perf_file_section {
u64 offset;
u64 size;
};
/**
* struct perf_file_header: Header representation on disk.
*/
struct perf_file_header {
/** @magic: Holds "PERFILE2". */
u64 magic;
/** @size: Size of this header - sizeof(struct perf_file_header). */
u64 size;
/**
* @attr_size: Size of attrs entries - sizeof(struct perf_event_attr) +
* sizeof(struct perf_file_section).
*/
u64 attr_size;
/** @attrs: Offset and size of file section holding attributes. */
struct perf_file_section attrs;
/** @data: Offset and size of file section holding regular event data. */
struct perf_file_section data;
/** @event_types: Ignored. */
struct perf_file_section event_types;
/**
* @adds_features: Bitmap of features. The features are immediately after the data section.
*/
DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
};
struct perf_pipe_file_header {
u64 magic;
u64 size;
};
int perf_file_header__read(struct perf_file_header *header,
struct perf_header *ph, int fd);
struct perf_header {
enum perf_header_version version;
bool needs_swap;
u64 data_offset;
u64 data_size;
u64 feat_offset;
DECLARE_BITMAP(adds_features, HEADER_FEAT_BITS);
int last_feat;
struct perf_env env;
};
struct feat_fd {
struct perf_header *ph;
int fd;
void *buf; /* Either buf != NULL or fd >= 0 */
ssize_t offset;
size_t size;
struct evsel *events;
};
struct perf_header_feature_ops {
int (*write)(struct feat_fd *ff, struct evlist *evlist);
void (*print)(struct feat_fd *ff, FILE *fp);
int (*process)(struct feat_fd *ff, void *data);
const char *name;
bool full_only;
bool synthesize;
};
extern const char perf_version_string[];
const char *header_feat__name(unsigned int id);
int perf_session__read_header(struct perf_session *session);
int perf_session__write_header(struct perf_session *session,
struct evlist *evlist,
int fd, bool at_exit);
int perf_header__write_pipe(int fd);
/* feat_writer writes a feature section to output */
struct feat_writer {
int (*write)(struct feat_writer *fw, void *buf, size_t sz);
};
/* feat_copier copies a feature section using feat_writer to output */
struct feat_copier {
int (*copy)(struct feat_copier *fc, int feat, struct feat_writer *fw);
};
int perf_session__inject_header(struct perf_session *session,
struct evlist *evlist,
int fd,
Annotation
- Immediate include surface: `linux/stddef.h`, `linux/perf_event.h`, `sys/types.h`, `stdio.h`, `stdbool.h`, `linux/bitmap.h`, `linux/types.h`, `env.h`.
- Detected declarations: `struct evlist`, `struct perf_header`, `struct perf_session`, `struct perf_tool`, `struct perf_file_section`, `struct perf_file_header`, `struct perf_pipe_file_header`, `struct perf_header`, `struct feat_fd`, `struct perf_header_feature_ops`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.