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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
builtin.hutil/build-id.hsubcmd/parse-options.hinternal/xyarray.hutil/parse-events.hutil/config.hutil/callchain.hutil/cgroup.hutil/header.hutil/event.hutil/evlist.hutil/evsel.hutil/debug.hutil/mmap.hutil/mutex.hutil/target.hutil/session.hutil/tool.hutil/stat.hutil/symbol.hutil/record.hutil/cpumap.hutil/thread_map.hutil/data.hutil/perf_regs.hutil/auxtrace.hutil/tsc.hutil/parse-branch-options.hutil/parse-regs-options.hutil/perf_api_probe.hutil/trigger.hutil/perf-hooks.h
Detected Declarations
struct switch_outputstruct thread_maskstruct record_threadstruct pollfd_index_mapstruct recordstruct record_aioenum thread_msgenum thread_specfunction gettidfunction record__threads_enabledfunction switch_output_signalfunction switch_output_sizefunction switch_output_timefunction record__bytes_writtenfunction record__output_max_size_exceededfunction record__writefunction record__aio_writefunction record__aio_completefunction record__aio_syncfunction record__aio_pushfnfunction perf_mmap__consumefunction record__aio_pushfunction record__aio_get_posfunction record__aio_set_posfunction record__aio_mmap_read_syncfunction record__aio_parsefunction record__aio_pushfunction record__aio_get_posfunction record__aio_set_posfunction record__mmap_flush_parsefunction record__parse_comp_levelfunction record__comp_enabledfunction process_synthesized_eventfunction process_locked_synthesized_eventfunction record__pushfnfunction sig_handlerfunction sigsegv_handlerfunction record__sig_exitfunction record__process_auxtracefunction record__auxtrace_mmap_readfunction record__auxtrace_mmap_read_snapshotfunction record__auxtrace_read_snapshot_allfunction record__read_auxtrace_snapshotfunction record__auxtrace_snapshot_exitfunction record__auxtrace_initfunction record__config_text_pokefunction record__config_off_cpufunction record__tracking_system_wide
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
- Immediate include surface: `builtin.h`, `util/build-id.h`, `subcmd/parse-options.h`, `internal/xyarray.h`, `util/parse-events.h`, `util/config.h`, `util/callchain.h`, `util/cgroup.h`.
- Detected declarations: `struct switch_output`, `struct thread_mask`, `struct record_thread`, `struct pollfd_index_map`, `struct record`, `struct record_aio`, `enum thread_msg`, `enum thread_spec`, `function gettid`, `function record__threads_enabled`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.