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.

Dependency Surface

Detected Declarations

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

Implementation Notes