tools/perf/util/intel-pt.c
Source file repositories/reference/linux-study-clean/tools/perf/util/intel-pt.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/intel-pt.c- Extension
.c- Size
- 121093 bytes
- Lines
- 4726
- 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
inttypes.hlinux/perf_event.hstdio.hstdbool.herrno.hlinux/kernel.hlinux/string.hlinux/types.hlinux/zalloc.hsession.hmachine.hmemswap.hsort.htool.hevent.hevlist.hevsel.hmap.hcolor.hthread.hthread-stack.hsymbol.hcallchain.hdso.hdebug.hauxtrace.htsc.hintel-pt.hconfig.hutil/perf_api_probe.hutil/synthetic-events.htime-utils.h
Detected Declarations
struct rangestruct intel_ptstruct intel_pt_pebs_eventstruct intel_pt_queuestruct intel_pt_cache_entrystruct dummy_branch_stackenum switch_stateenum DATA_SRC_FORMATfunction intel_pt_dumpfunction intel_pt_dump_eventfunction intel_pt_log_eventfunction intel_pt_dump_samplefunction intel_pt_log_eventsfunction intel_pt_free_vmcs_infofunction intel_pt_do_fix_overlapfunction intel_pt_get_bufferfunction intel_pt_lookahead_drop_bufferfunction intel_pt_lookaheadfunction intel_pt_lookaheadfunction intel_pt_config_divfunction intel_pt_cache_divisorfunction intel_pt_cache_sizefunction intel_pt_cache_addfunction intel_pt_cache_lookupfunction intel_pt_cache_invalidatefunction intel_pt_guest_kernel_ipfunction intel_pt_nr_cpumodefunction intel_pt_cpumodefunction intel_pt_get_guestfunction intel_pt_jmp_16function intel_pt_emulated_ptwritefunction intel_pt_walk_next_insnfunction intel_pt_get_guestfunction intel_pt_match_pgd_ipfunction list_for_each_entryfunction __intel_pt_pgd_ipfunction intel_pt_pgd_ipfunction intel_pt_get_configfunction intel_pt_exclude_kernelfunction evlist__for_each_entryfunction intel_pt_return_compressionfunction evlist__for_each_entryfunction intel_pt_branch_enablefunction evlist__for_each_entryfunction intel_pt_disabled_tntfunction evlist__for_each_entryfunction intel_pt_mtc_periodfunction evlist__for_each_entry
Annotated Snippet
pid = event->context_switch.next_prev_pid;
tid = event->context_switch.next_prev_tid;
} else {
if (out)
return 0;
pid = sample->pid;
tid = sample->tid;
}
if (tid == -1)
intel_pt_log("context_switch event has no tid\n");
ret = intel_pt_sync_switch(pt, cpu, tid, sample->time);
if (ret <= 0)
return ret;
return machine__set_current_tid(pt->machine, cpu, pid, tid);
}
static int intel_pt_process_itrace_start(struct intel_pt *pt,
union perf_event *event,
struct perf_sample *sample)
{
if (!pt->per_cpu_mmaps)
return 0;
intel_pt_log("itrace_start: cpu %d pid %d tid %d time %"PRIu64" tsc %#"PRIx64"\n",
sample->cpu, event->itrace_start.pid,
event->itrace_start.tid, sample->time,
perf_time_to_tsc(sample->time, &pt->tc));
return machine__set_current_tid(pt->machine, sample->cpu,
event->itrace_start.pid,
event->itrace_start.tid);
}
/*
* Events with data_src are identified by L1_Hit_Indication
* refer https://github.com/intel/perfmon
*/
static int intel_pt_data_src_fmt(struct intel_pt *pt, struct evsel *evsel)
{
struct perf_env *env = pt->machine->env;
int fmt = DATA_SRC_FORMAT_NA;
if (!env->cpuid)
return DATA_SRC_FORMAT_ERR;
/*
* PEBS-via-PT is only supported on E-core non-hybrid. Of those only
* Gracemont and Crestmont have data_src. Check for:
* Alderlake N (Gracemont)
* Sierra Forest (Crestmont)
* Grand Ridge (Crestmont)
*/
if (!strncmp(env->cpuid, "GenuineIntel,6,190,", 19))
fmt = DATA_SRC_FORMAT_GRT;
if (!strncmp(env->cpuid, "GenuineIntel,6,175,", 19) ||
!strncmp(env->cpuid, "GenuineIntel,6,182,", 19))
fmt = DATA_SRC_FORMAT_CMT;
if (fmt == DATA_SRC_FORMAT_NA)
return fmt;
/*
* Only data_src events are:
* mem-loads event=0xd0,umask=0x5
* mem-stores event=0xd0,umask=0x6
*/
if (evsel->core.attr.type == PERF_TYPE_RAW &&
((evsel->core.attr.config & 0xffff) == 0x5d0 ||
(evsel->core.attr.config & 0xffff) == 0x6d0))
return fmt;
return DATA_SRC_FORMAT_NA;
}
static int intel_pt_process_aux_output_hw_id(struct intel_pt *pt,
union perf_event *event,
struct perf_sample *sample)
{
u64 hw_id = event->aux_output_hw_id.hw_id;
struct auxtrace_queue *queue;
struct intel_pt_queue *ptq;
struct evsel *evsel;
queue = auxtrace_queues__sample_queue(&pt->queues, sample, pt->session);
evsel = evlist__id2evsel_strict(pt->session->evlist, sample->id);
Annotation
- Immediate include surface: `inttypes.h`, `linux/perf_event.h`, `stdio.h`, `stdbool.h`, `errno.h`, `linux/kernel.h`, `linux/string.h`, `linux/types.h`.
- Detected declarations: `struct range`, `struct intel_pt`, `struct intel_pt_pebs_event`, `struct intel_pt_queue`, `struct intel_pt_cache_entry`, `struct dummy_branch_stack`, `enum switch_state`, `enum DATA_SRC_FORMAT`, `function intel_pt_dump`, `function intel_pt_dump_event`.
- 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.