tools/perf/builtin-record.c

Source file repositories/reference/linux-study-clean/tools/perf/builtin-record.c

File Facts

System
Linux kernel
Corpus path
tools/perf/builtin-record.c
Extension
.c
Size
120732 bytes
Lines
4421
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 switch_output {
	bool		 enabled;
	bool		 signal;
	unsigned long	 size;
	unsigned long	 time;
	const char	*str;
	bool		 set;
	char		 **filenames;
	int		 num_files;
	int		 cur_file;
};

struct thread_mask {
	struct mmap_cpu_mask	maps;
	struct mmap_cpu_mask	affinity;
};

struct record_thread {
	pid_t			tid;
	struct thread_mask	*mask;
	struct {
		int		msg[2];
		int		ack[2];
	} pipes;
	struct fdarray		pollfd;
	int			ctlfd_pos;
	int			nr_mmaps;
	struct mmap		**maps;
	struct mmap		**overwrite_maps;
	struct record		*rec;
	unsigned long long	samples;
	unsigned long		waking;
	u64			bytes_written;
	u64			bytes_transferred;
	u64			bytes_compressed;
};

static __thread struct record_thread *thread;

enum thread_msg {
	THREAD_MSG__UNDEFINED = 0,
	THREAD_MSG__READY,
	THREAD_MSG__MAX,
};

static const char *thread_msg_tags[THREAD_MSG__MAX] = {
	"UNDEFINED", "READY"
};

enum thread_spec {
	THREAD_SPEC__UNDEFINED = 0,
	THREAD_SPEC__CPU,
	THREAD_SPEC__CORE,
	THREAD_SPEC__PACKAGE,
	THREAD_SPEC__NUMA,
	THREAD_SPEC__USER,
	THREAD_SPEC__MAX,
};

static const char *thread_spec_tags[THREAD_SPEC__MAX] = {
	"undefined", "cpu", "core", "package", "numa", "user"
};

struct pollfd_index_map {
	int evlist_pollfd_index;
	int thread_pollfd_index;
};

struct record {
	struct perf_tool	tool;
	struct record_opts	opts;
	u64			bytes_written;
	u64			thread_bytes_written;
	struct perf_data	data;
	struct auxtrace_record	*itr;
	struct evlist	*evlist;
	struct perf_session	*session;
	struct evlist		*sb_evlist;
	pthread_t		thread_id;
	int			realtime_prio;
	bool			latency;
	bool			switch_output_event_set;
	bool			no_buildid;
	bool			no_buildid_set;
	bool			no_buildid_cache;
	bool			no_buildid_cache_set;
	bool			buildid_all;
	bool			buildid_mmap;
	bool			buildid_mmap_set;
	bool			timestamp_filename;

Annotation

Implementation Notes