tools/perf/util/record.c
Source file repositories/reference/linux-study-clean/tools/perf/util/record.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/record.c- Extension
.c- Size
- 7716 bytes
- Lines
- 292
- 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
debug.hevlist.hevsel.hevsel_config.hparse-events.herrno.hlimits.hstdlib.hapi/fs/fs.hsubcmd/parse-options.hperf/cpumap.hcloexec.hutil/perf_api_probe.hrecord.h../perf-sys.htopdown.hmap_symbol.hmem-events.h
Detected Declarations
function evsel__config_leader_samplingfunction evsel__config_term_maskfunction list_for_each_entryfunction evsel__config_leader_samplingfunction evlist__configfunction evlist__for_each_entryfunction evlist__for_each_entryfunction get_max_ratefunction record_opts__config_freqfunction record_opts__configfunction evlist__can_select_eventfunction record__parse_freq
Annotated Snippet
is_mem_loads_aux_event(leader)) {
evlist__for_each_entry(evlist, evsel) {
if (evsel__leader(evsel) == leader && evsel != evsel__leader(evsel))
return evsel;
}
}
return leader;
}
static u64 evsel__config_term_mask(struct evsel *evsel)
{
struct evsel_config_term *term;
struct list_head *config_terms = &evsel->config_terms;
u64 term_types = 0;
list_for_each_entry(term, config_terms, list) {
term_types |= 1 << term->type;
}
return term_types;
}
static void evsel__config_leader_sampling(struct evsel *evsel, struct evlist *evlist)
{
struct perf_event_attr *attr = &evsel->core.attr;
struct evsel *leader = evsel__leader(evsel);
struct evsel *read_sampler;
u64 term_types, freq_mask;
if (!leader->sample_read)
return;
read_sampler = evsel__read_sampler(evsel, evlist);
if (evsel == read_sampler)
return;
term_types = evsel__config_term_mask(evsel);
/*
* Disable sampling for all group members except those with explicit
* config terms or the leader. In the case of an AUX area event, the 2nd
* event in the group is the one that 'leads' the sampling.
*/
freq_mask = (1 << EVSEL__CONFIG_TERM_FREQ) | (1 << EVSEL__CONFIG_TERM_PERIOD);
if ((term_types & freq_mask) == 0) {
attr->freq = 0;
attr->sample_freq = 0;
attr->sample_period = 0;
}
if ((term_types & (1 << EVSEL__CONFIG_TERM_OVERWRITE)) == 0)
attr->write_backward = 0;
/*
* We don't get a sample for slave events, we make them when delivering
* the group leader sample. Set the slave event to follow the master
* sample_type to ease up reporting.
* An AUX area event also has sample_type requirements, so also include
* the sample type bits from the leader's sample_type to cover that
* case.
*/
attr->sample_type = read_sampler->core.attr.sample_type |
leader->core.attr.sample_type;
}
void evlist__config(struct evlist *evlist, struct record_opts *opts, struct callchain_param *callchain)
{
struct evsel *evsel;
bool use_sample_identifier = false;
bool use_comm_exec;
bool sample_id = opts->sample_id;
if (perf_cpu_map__cpu(evlist->core.user_requested_cpus, 0).cpu < 0)
opts->no_inherit = true;
use_comm_exec = perf_can_comm_exec();
evlist__for_each_entry(evlist, evsel) {
evsel__config(evsel, opts, callchain);
if (evsel->tracking && use_comm_exec)
evsel->core.attr.comm_exec = 1;
}
/* Configure leader sampling here now that the sample type is known */
evlist__for_each_entry(evlist, evsel)
evsel__config_leader_sampling(evsel, evlist);
if (opts->full_auxtrace || opts->sample_identifier) {
/*
* Need to be able to synthesize and parse selected events with
* arbitrary sample types, which requires always being able to
Annotation
- Immediate include surface: `debug.h`, `evlist.h`, `evsel.h`, `evsel_config.h`, `parse-events.h`, `errno.h`, `limits.h`, `stdlib.h`.
- Detected declarations: `function evsel__config_leader_sampling`, `function evsel__config_term_mask`, `function list_for_each_entry`, `function evsel__config_leader_sampling`, `function evlist__config`, `function evlist__for_each_entry`, `function evlist__for_each_entry`, `function get_max_rate`, `function record_opts__config_freq`, `function record_opts__config`.
- 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.