tools/perf/arch/x86/util/intel-pt.c
Source file repositories/reference/linux-study-clean/tools/perf/arch/x86/util/intel-pt.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/arch/x86/util/intel-pt.c- Extension
.c- Size
- 32256 bytes
- Lines
- 1231
- 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
errno.hstdbool.hlinux/kernel.hlinux/types.hlinux/bitops.hlinux/log2.hlinux/zalloc.hlinux/err.h../../../util/session.h../../../util/event.h../../../util/evlist.h../../../util/evsel.h../../../util/evsel_config.h../../../util/config.h../../../util/cpumap.h../../../util/mmap.hsubcmd/parse-options.h../../../util/parse-events.h../../../util/pmus.h../../../util/debug.h../../../util/auxtrace.h../../../util/perf_api_probe.h../../../util/record.h../../../util/target.h../../../util/tsc.hinternal/lib.h../../../util/intel-pt.hapi/fs/fs.hcpuid.h
Detected Declarations
struct intel_pt_snapshot_refstruct intel_pt_recordingfunction intel_pt_parse_terms_with_defaultfunction intel_pt_parse_termsfunction intel_pt_masked_bitsfunction intel_pt_read_configfunction evlist__for_each_entryfunction intel_pt_psb_periodfunction intel_pt_pick_bitfunction intel_pt_default_configfunction intel_pt_parse_snapshot_optionsfunction intel_pt_pmu_default_configfunction evlist__for_each_entryfunction intel_pt_filter_bytesfunction intel_pt_info_priv_sizefunction intel_pt_tsc_ctc_ratiofunction intel_pt_info_fillfunction intel_pt_track_switchesfunction intel_pt_exclude_guestfunction intel_pt_valid_strfunction intel_pt_val_config_termfunction intel_pt_validate_configfunction intel_pt_min_max_sample_szfunction evlist__for_each_entryfunction intel_pt_too_many_aux_outputfunction intel_pt_recording_optionsfunction evlist__for_each_entryfunction intel_pt_snapshot_startfunction evlist__for_each_entryfunction intel_pt_snapshot_finishfunction evlist__for_each_entryfunction intel_pt_alloc_snapshot_refsfunction intel_pt_free_snapshot_refsfunction intel_pt_recording_freefunction intel_pt_alloc_snapshot_reffunction intel_pt_snapshot_ref_buf_sizefunction intel_pt_snapshot_initfunction intel_pt_compare_buffersfunction intel_pt_compare_reffunction intel_pt_copy_reffunction intel_pt_wrappedfunction intel_pt_first_wrapfunction intel_pt_find_snapshotfunction intel_pt_referencefunction intel_pt_perf_config
Annotated Snippet
switch_evsel->core.attr.context_switch = 1;
switch_evsel->immediate = true;
evsel__set_sample_bit(switch_evsel, TID);
evsel__set_sample_bit(switch_evsel, TIME);
evsel__set_sample_bit(switch_evsel, CPU);
evsel__reset_sample_bit(switch_evsel, BRANCH_STACK);
opts->record_switch_events = false;
ptr->have_sched_switch = 3;
} else {
opts->record_switch_events = true;
need_immediate = true;
if (cpu_wide)
ptr->have_sched_switch = 3;
else
ptr->have_sched_switch = 2;
}
} else {
#ifdef HAVE_LIBTRACEEVENT
err = intel_pt_track_switches(evlist);
if (err == -EPERM)
pr_debug2("Unable to select sched:sched_switch\n");
else if (err)
return err;
else
ptr->have_sched_switch = 1;
#endif
}
}
if (have_timing_info && !intel_pt_evsel->core.attr.exclude_kernel &&
perf_can_record_text_poke_events() && perf_can_record_cpu_wide())
opts->text_poke = true;
if (intel_pt_evsel) {
/*
* To obtain the auxtrace buffer file descriptor, the auxtrace
* event must come first.
*/
evlist__to_front(evlist, intel_pt_evsel);
/*
* In the case of per-cpu mmaps, we need the CPU on the
* AUX event.
*/
if (!perf_cpu_map__is_any_cpu_or_is_empty(cpus))
evsel__set_sample_bit(intel_pt_evsel, CPU);
}
/* Add dummy event to keep tracking */
if (opts->full_auxtrace) {
bool need_system_wide_tracking;
struct evsel *tracking_evsel;
/*
* User space tasks can migrate between CPUs, so when tracing
* selected CPUs, sideband for all CPUs is still needed.
*/
need_system_wide_tracking = opts->target.cpu_list &&
!intel_pt_evsel->core.attr.exclude_user;
tracking_evsel = evlist__add_aux_dummy(evlist, need_system_wide_tracking);
if (!tracking_evsel)
return -ENOMEM;
evlist__set_tracking_event(evlist, tracking_evsel);
if (need_immediate)
tracking_evsel->immediate = true;
/* In per-cpu case, always need the time of mmap events etc */
if (!perf_cpu_map__is_any_cpu_or_is_empty(cpus)) {
evsel__set_sample_bit(tracking_evsel, TIME);
/* And the CPU for switch events */
evsel__set_sample_bit(tracking_evsel, CPU);
}
evsel__reset_sample_bit(tracking_evsel, BRANCH_STACK);
}
/*
* Warn the user when we do not have enough information to decode i.e.
* per-cpu with no sched_switch (except workload-only).
*/
if (!ptr->have_sched_switch && !perf_cpu_map__is_any_cpu_or_is_empty(cpus) &&
!target__none(&opts->target) &&
!intel_pt_evsel->core.attr.exclude_user)
ui__warning("Intel Processor Trace decoding will not be possible except for kernel tracing!\n");
return 0;
}
Annotation
- Immediate include surface: `errno.h`, `stdbool.h`, `linux/kernel.h`, `linux/types.h`, `linux/bitops.h`, `linux/log2.h`, `linux/zalloc.h`, `linux/err.h`.
- Detected declarations: `struct intel_pt_snapshot_ref`, `struct intel_pt_recording`, `function intel_pt_parse_terms_with_default`, `function intel_pt_parse_terms`, `function intel_pt_masked_bits`, `function intel_pt_read_config`, `function evlist__for_each_entry`, `function intel_pt_psb_period`, `function intel_pt_pick_bit`, `function intel_pt_default_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.