tools/perf/util/intel-bts.c
Source file repositories/reference/linux-study-clean/tools/perf/util/intel-bts.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/intel-bts.c- Extension
.c- Size
- 22321 bytes
- Lines
- 911
- 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
endian.herrno.hbyteswap.hinttypes.hlinux/kernel.hlinux/types.hlinux/bitops.hlinux/log2.hlinux/zalloc.hcolor.hevsel.hevlist.hmachine.hsymbol.hsession.htool.hthread.hthread-stack.hdebug.htsc.hauxtrace.hintel-pt-decoder/intel-pt-insn-decoder.hintel-bts.hutil/synthetic-events.h
Detected Declarations
struct intel_btsstruct intel_bts_queuestruct branchfunction intel_bts_dumpfunction intel_bts_dump_eventfunction intel_bts_lostfunction intel_bts_setup_queuefunction intel_bts_setup_queuesfunction intel_bts_update_queuesfunction intel_bts_do_fix_overlapfunction intel_bts_cpumodefunction intel_bts_synth_branch_samplefunction intel_bts_get_next_insnfunction intel_bts_synth_errorfunction intel_bts_get_branch_typefunction intel_bts_process_bufferfunction intel_bts_process_queuefunction intel_bts_flush_queuefunction intel_bts_process_tid_exitfunction intel_bts_process_queuesfunction intel_bts_process_eventfunction intel_bts_process_auxtrace_eventfunction intel_bts_flushfunction intel_bts_free_queuefunction intel_bts_free_eventsfunction intel_bts_freefunction intel_bts_evsel_is_auxtracefunction intel_bts_synth_eventsfunction evlist__for_each_entryfunction intel_bts_print_infofunction intel_bts_process_auxtrace_info
Annotated Snippet
struct intel_bts {
struct auxtrace auxtrace;
struct auxtrace_queues queues;
struct auxtrace_heap heap;
u32 auxtrace_type;
struct perf_session *session;
struct machine *machine;
bool sampling_mode;
bool snapshot_mode;
bool data_queued;
u32 pmu_type;
struct perf_tsc_conversion tc;
bool cap_user_time_zero;
struct itrace_synth_opts synth_opts;
bool sample_branches;
u32 branches_filter;
u64 branches_sample_type;
u64 branches_id;
size_t branches_event_size;
unsigned long num_events;
};
struct intel_bts_queue {
struct intel_bts *bts;
unsigned int queue_nr;
struct auxtrace_buffer *buffer;
bool on_heap;
bool done;
pid_t pid;
pid_t tid;
int cpu;
u64 time;
struct intel_pt_insn intel_pt_insn;
u32 sample_flags;
};
struct branch {
u64 from;
u64 to;
u64 misc;
};
static void intel_bts_dump(struct intel_bts *bts __maybe_unused,
unsigned char *buf, size_t len)
{
struct branch *branch;
size_t i, pos = 0, br_sz = sizeof(struct branch), sz;
const char *color = PERF_COLOR_BLUE;
color_fprintf(stdout, color,
". ... Intel BTS data: size %zu bytes\n",
len);
while (len) {
if (len >= br_sz)
sz = br_sz;
else
sz = len;
printf(".");
color_fprintf(stdout, color, " %08zx: ", pos);
for (i = 0; i < sz; i++)
color_fprintf(stdout, color, " %02x", buf[i]);
for (; i < br_sz; i++)
color_fprintf(stdout, color, " ");
if (len >= br_sz) {
branch = (struct branch *)buf;
color_fprintf(stdout, color, " %"PRIx64" -> %"PRIx64" %s\n",
le64_to_cpu(branch->from),
le64_to_cpu(branch->to),
le64_to_cpu(branch->misc) & 0x10 ?
"pred" : "miss");
} else {
color_fprintf(stdout, color, " Bad record!\n");
}
pos += sz;
buf += sz;
len -= sz;
}
}
static void intel_bts_dump_event(struct intel_bts *bts, unsigned char *buf,
size_t len)
{
printf(".\n");
intel_bts_dump(bts, buf, len);
}
static int intel_bts_lost(struct intel_bts *bts, struct perf_sample *sample)
{
union perf_event event;
Annotation
- Immediate include surface: `endian.h`, `errno.h`, `byteswap.h`, `inttypes.h`, `linux/kernel.h`, `linux/types.h`, `linux/bitops.h`, `linux/log2.h`.
- Detected declarations: `struct intel_bts`, `struct intel_bts_queue`, `struct branch`, `function intel_bts_dump`, `function intel_bts_dump_event`, `function intel_bts_lost`, `function intel_bts_setup_queue`, `function intel_bts_setup_queues`, `function intel_bts_update_queues`, `function intel_bts_do_fix_overlap`.
- 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.