tools/perf/builtin-trace.c
Source file repositories/reference/linux-study-clean/tools/perf/builtin-trace.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/builtin-trace.c- Extension
.c- Size
- 167890 bytes
- Lines
- 5794
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
util/record.hapi/fs/tracing_path.hbpf/bpf.hbpf/libbpf.hbpf/btf.hutil/rlimit.hbuiltin.hutil/cgroup.hutil/color.hutil/config.hutil/debug.hutil/dso.hutil/env.hutil/event.hutil/evsel.hutil/evsel_fprintf.hutil/synthetic-events.hutil/evlist.hutil/evswitch.hutil/hashmap.hutil/mmap.hsubcmd/pager.hsubcmd/exec-cmd.hutil/machine.hutil/map.hutil/symbol.hutil/path.hutil/session.hutil/thread.hsubcmd/parse-options.hutil/strlist.hutil/intlist.h
Detected Declarations
struct syscall_arg_fmtstruct syscall_fmtstruct tracestruct tp_fieldstruct syscall_tpstruct evsel_tracestruct trace_btf_dump_snprintf_ctxstruct syscallstruct thread_tracestruct syscall_statsstruct syscall_entryfunction trace__load_vmlinux_btffunction __tp_field__init_uintfunction tp_field__init_uintfunction __tp_field__init_ptrfunction tp_field__init_ptrfunction evsel_trace__deletefunction evsel__init_tp_uint_fieldfunction evsel__init_tp_ptr_fieldfunction evsel__delete_privfunction evsel__init_syscall_tpfunction evsel__init_augmented_syscall_tpfunction evsel__init_augmented_syscall_tp_argsfunction evsel__init_augmented_syscall_tp_retfunction evsel__init_raw_syscall_tpfunction strarray__scnprintf_suffixfunction strarray__scnprintffunction __syscall_arg__scnprintf_strarrayfunction syscall_arg__scnprintf_strarrayfunction syscall_arg__strtoul_strarrayfunction syscall_arg__strtoul_strarray_flagsfunction syscall_arg__strtoul_strarraysfunction syscall_arg__scnprintf_strarray_flagsfunction strarrays__scnprintffunction strarray__strtoulfunction strarray__strtoul_flagsfunction strarrays__strtoulfunction syscall_arg__scnprintf_strarraysfunction syscall_arg__scnprintf_fd_atfunction syscall_arg__scnprintf_hexfunction syscall_arg__scnprintf_ptrfunction syscall_arg__scnprintf_intfunction syscall_arg__scnprintf_longfunction syscall_arg__scnprintf_char_arrayfunction syscall_arg__scnprintf_access_modefunction syscall_arg__scnprintf_pipe_flagsfunction syscall_arg__scnprintf_getrandom_flagsfunction syscall_arg_fmt__cache_btf_enum
Annotated Snippet
struct syscall_arg_fmt {
size_t (*scnprintf)(char *bf, size_t size, struct syscall_arg *arg);
bool (*strtoul)(char *bf, size_t size, struct syscall_arg *arg, u64 *val);
unsigned long (*mask_val)(struct syscall_arg *arg, unsigned long val);
void *parm;
const char *name;
u16 nr_entries; // for arrays
bool from_user;
bool show_zero;
#ifdef HAVE_LIBBPF_SUPPORT
const struct btf_type *type;
int type_id; /* used in btf_dump */
#endif
};
struct syscall_fmt {
const char *name;
const char *alias;
struct {
const char *sys_enter,
*sys_exit;
} bpf_prog_name;
struct syscall_arg_fmt arg[RAW_SYSCALL_ARGS_NUM];
u8 nr_args;
bool errpid;
bool timeout;
bool hexret;
};
struct trace {
struct perf_env host_env;
struct perf_tool tool;
struct {
/** Sorted sycall numbers used by the trace. */
struct syscall **table;
/** Size of table. */
size_t table_size;
struct {
struct evsel *sys_enter,
*sys_exit,
*bpf_output;
} events;
} syscalls;
#ifdef HAVE_LIBBPF_SUPPORT
struct btf *btf;
#endif
struct record_opts opts;
struct evlist *evlist;
struct machine *host;
struct thread *current;
struct cgroup *cgroup;
u64 base_time;
FILE *output;
unsigned long nr_events;
unsigned long nr_events_printed;
unsigned long max_events;
struct evswitch evswitch;
struct strlist *ev_qualifier;
struct {
size_t nr;
int *entries;
} ev_qualifier_ids;
struct {
size_t nr;
pid_t *entries;
struct bpf_map *map;
} filter_pids;
/*
* TODO: The map is from an ID (aka system call number) to struct
* syscall_stats. If there is >1 e_machine, such as i386 and x86-64
* processes, then the stats here will gather wrong the statistics for
* the non EM_HOST system calls. A fix would be to add the e_machine
* into the key, but this would make the code inconsistent with the
* per-thread version.
*/
struct hashmap *syscall_stats;
double duration_filter;
double runtime_ms;
unsigned long pfmaj, pfmin;
struct {
u64 vfs_getname,
proc_getname;
} stats;
unsigned int max_stack;
unsigned int min_stack;
enum trace_summary_mode summary_mode;
int max_summary;
int raw_augmented_syscalls_args_size;
bool raw_augmented_syscalls;
bool fd_path_disabled;
Annotation
- Immediate include surface: `util/record.h`, `api/fs/tracing_path.h`, `bpf/bpf.h`, `bpf/libbpf.h`, `bpf/btf.h`, `util/rlimit.h`, `builtin.h`, `util/cgroup.h`.
- Detected declarations: `struct syscall_arg_fmt`, `struct syscall_fmt`, `struct trace`, `struct tp_field`, `struct syscall_tp`, `struct evsel_trace`, `struct trace_btf_dump_snprintf_ctx`, `struct syscall`, `struct thread_trace`, `struct syscall_stats`.
- 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.
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.