tools/perf/util/auxtrace.c
Source file repositories/reference/linux-study-clean/tools/perf/util/auxtrace.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/auxtrace.c- Extension
.c- Size
- 68505 bytes
- Lines
- 2963
- 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.hsys/types.hsys/mman.hstdbool.hstring.hlimits.herrno.hlinux/kernel.hlinux/perf_event.hlinux/types.hlinux/bitops.hlinux/log2.hlinux/string.hlinux/time64.hsys/param.hstdlib.hstdio.hlinux/list.hlinux/zalloc.hconfig.hevlist.hdso.hmap.hpmu.hevsel.hevsel_config.hsymbol.hutil/perf_api_probe.hutil/synthetic-events.hthread_map.hasm/bug.hauxtrace.h
Detected Declarations
struct queue_datastruct auxtrace_cachestruct sym_argsfunction Copyrightfunction evlist__regroupfunction auxtrace__dont_decodefunction auxtrace_mmap__mmapfunction auxtrace_mmap__munmapfunction auxtrace_mmap_params__initfunction auxtrace_mmap_params__set_idxfunction auxtrace_queues__init_nrfunction auxtrace_queues__initfunction auxtrace_queues__growfunction auxtrace_queues__queue_bufferfunction auxtrace_queues__split_bufferfunction filter_cpufunction auxtrace_queues__add_bufferfunction auxtrace_queues__add_eventfunction auxtrace_queues__add_indexed_eventfunction auxtrace_queues__freefunction auxtrace_heapifyfunction auxtrace_heap__addfunction auxtrace_heap__freefunction auxtrace_heap__popfunction auxtrace_record__info_priv_sizefunction auxtrace_not_supportedfunction auxtrace_record__info_fillfunction auxtrace_record__freefunction auxtrace_record__snapshot_startfunction auxtrace_record__snapshot_finishfunction auxtrace_record__find_snapshotfunction auxtrace_record__optionsfunction auxtrace_record__referencefunction auxtrace_parse_snapshot_optionsfunction evlist__enable_event_idxfunction auxtrace_record__read_finishfunction evlist__for_each_entryfunction auxtrace_validate_aux_sample_sizefunction evlist__for_each_entryfunction auxtrace_parse_sample_optionsfunction auxtrace_parse_aux_actionfunction evlist__for_each_entryfunction auxtrace_record__initfunction auxtrace_index__allocfunction auxtrace_index__freefunction list_for_each_entry_safefunction auxtrace_index__auxtrace_eventfunction auxtrace_index__do_write
Annotated Snippet
struct queue_data {
bool samples;
bool events;
};
static int auxtrace_queue_data_cb(struct perf_session *session,
union perf_event *event, u64 offset,
void *data)
{
struct queue_data *qd = data;
struct perf_sample sample;
int err;
if (qd->events && event->header.type == PERF_RECORD_AUXTRACE) {
if (event->header.size < sizeof(struct perf_record_auxtrace))
return -EINVAL;
offset += event->header.size;
return session->auxtrace->queue_data(session, NULL, event,
offset);
}
if (!qd->samples || event->header.type != PERF_RECORD_SAMPLE)
return 0;
perf_sample__init(&sample, /*all=*/false);
err = evlist__parse_sample(session->evlist, event, &sample);
if (err)
goto out;
if (sample.aux_sample.size) {
offset += sample.aux_sample.data - (void *)event;
err = session->auxtrace->queue_data(session, &sample, NULL, offset);
}
out:
perf_sample__exit(&sample);
return err;
}
int auxtrace_queue_data(struct perf_session *session, bool samples, bool events)
{
struct queue_data qd = {
.samples = samples,
.events = events,
};
if (auxtrace__dont_decode(session))
return 0;
if (perf_data__is_pipe(session->data))
return 0;
if (!session->auxtrace || !session->auxtrace->queue_data)
return -EINVAL;
return perf_session__peek_events(session, session->header.data_offset,
session->header.data_size,
auxtrace_queue_data_cb, &qd);
}
void *auxtrace_buffer__get_data_rw(struct auxtrace_buffer *buffer, int fd, bool rw)
{
int prot = rw ? PROT_READ | PROT_WRITE : PROT_READ;
size_t adj = buffer->data_offset & (page_size - 1);
size_t size = buffer->size + adj;
off_t file_offset = buffer->data_offset - adj;
void *addr;
if (buffer->data)
return buffer->data;
addr = mmap(NULL, size, prot, MAP_SHARED, fd, file_offset);
if (addr == MAP_FAILED)
return NULL;
buffer->mmap_addr = addr;
buffer->mmap_size = size;
buffer->data = addr + adj;
return buffer->data;
}
void auxtrace_buffer__put_data(struct auxtrace_buffer *buffer)
{
if (!buffer->data || !buffer->mmap_addr)
return;
munmap(buffer->mmap_addr, buffer->mmap_size);
buffer->mmap_addr = NULL;
buffer->mmap_size = 0;
Annotation
- Immediate include surface: `inttypes.h`, `sys/types.h`, `sys/mman.h`, `stdbool.h`, `string.h`, `limits.h`, `errno.h`, `linux/kernel.h`.
- Detected declarations: `struct queue_data`, `struct auxtrace_cache`, `struct sym_args`, `function Copyright`, `function evlist__regroup`, `function auxtrace__dont_decode`, `function auxtrace_mmap__mmap`, `function auxtrace_mmap__munmap`, `function auxtrace_mmap_params__init`, `function auxtrace_mmap_params__set_idx`.
- 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.