tools/perf/util/cs-etm.c
Source file repositories/reference/linux-study-clean/tools/perf/util/cs-etm.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/cs-etm.c- Extension
.c- Size
- 102244 bytes
- Lines
- 3568
- 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
linux/bitfield.hlinux/bitops.hlinux/coresight-pmu.hlinux/err.hlinux/log2.hlinux/types.hlinux/zalloc.hstdlib.hauxtrace.hcolor.hcs-etm.hcs-etm-decoder/cs-etm-decoder.hdebug.hdso.hevlist.hintlist.hmachine.hmap.hperf.hsession.hmap_symbol.hbranch.hsymbol.htool.hthread.hthread-stack.htsc.htools/libc_compat.hutil/synthetic-events.hutil/util.h
Detected Declarations
struct cs_etm_auxtracestruct cs_etm_traceid_queuestruct cs_etm_queuestruct dummy_branch_stackenum cs_etm_formatfunction cs_etm__get_v7_protocol_versionfunction cs_etm__get_magicfunction cs_etm__get_cpufunction cs_etm__init_pid_fmtfunction cs_etm__get_pid_fmtfunction cs_etm__insert_trace_id_nodefunction cs_etm__map_trace_id_v0function cs_etm__process_trace_id_v0function cs_etm__process_trace_id_v0_1function cs_etm__metadata_get_trace_idfunction cs_etm__metadata_set_trace_idfunction get_cpu_data_idxfunction cs_etm__process_aux_output_hw_idfunction cs_etm__etmq_set_traceid_queue_timestampfunction cs_etm__etmq_get_timestampfunction cs_etm__clear_packet_queuefunction cs_etm__clear_all_packet_queuesfunction intlist__for_each_entryfunction cs_etm__init_traceid_queuefunction cs_etm__packet_swapfunction cs_etm__packet_dumpfunction cs_etm__set_trace_param_etmv3function cs_etm__set_trace_param_etmv4function cs_etm__set_trace_param_etefunction cs_etm__init_trace_paramsfunction intlist__for_each_entryfunction cs_etm__init_decoder_paramsfunction cs_etm__dump_eventfunction cs_etm__flush_eventsfunction cs_etm__free_traceid_queuesfunction intlist__for_each_entry_safefunction cs_etm__free_queuefunction cs_etm__free_eventsfunction cs_etm__freefunction cs_etm__evsel_is_auxtracefunction cs_etm__cpu_modefunction cs_etm__mem_accessfunction cs_etm__setup_queuefunction cs_etm__queue_first_cs_timestampfunction nibblefunction cs_etm__copy_last_branch_rbfunction cs_etm__reset_last_branch_rbfunction cs_etm__t32_instr_size
Annotated Snippet
event->context_switch.next_prev_pid,
event->context_switch.next_prev_tid);
if (!th)
return -ENOMEM;
thread__put(th);
return 0;
}
static int cs_etm__process_event(struct perf_session *session,
union perf_event *event,
struct perf_sample *sample,
const struct perf_tool *tool)
{
struct cs_etm_auxtrace *etm = container_of(session->auxtrace,
struct cs_etm_auxtrace,
auxtrace);
if (dump_trace)
return 0;
if (!tool->ordered_events) {
pr_err("CoreSight ETM Trace requires ordered events\n");
return -EINVAL;
}
switch (event->header.type) {
case PERF_RECORD_EXIT:
/*
* Don't need to wait for cs_etm__flush_events() in per-thread mode to
* start the decode because we know there will be no more trace from
* this thread. All this does is emit samples earlier than waiting for
* the flush in other modes, but with timestamps it makes sense to wait
* for flush so that events from different threads are interleaved
* properly.
*/
if (etm->per_thread_decoding && etm->timeless_decoding)
return cs_etm__process_timeless_queues(etm,
event->fork.tid);
break;
case PERF_RECORD_ITRACE_START:
return cs_etm__process_itrace_start(etm, event);
case PERF_RECORD_SWITCH_CPU_WIDE:
return cs_etm__process_switch_cpu_wide(etm, event);
case PERF_RECORD_AUX:
/*
* Record the latest kernel timestamp available in the header
* for samples so that synthesised samples occur from this point
* onwards.
*/
if (sample->time && (sample->time != (u64)-1))
etm->latest_kernel_timestamp = sample->time;
break;
default:
break;
}
return 0;
}
static void dump_queued_data(struct cs_etm_auxtrace *etm,
struct perf_record_auxtrace *event)
{
struct auxtrace_buffer *buf;
unsigned int i;
/*
* Find all buffers with same reference in the queues and dump them.
* This is because the queues can contain multiple entries of the same
* buffer that were split on aux records.
*/
for (i = 0; i < etm->queues.nr_queues; ++i)
list_for_each_entry(buf, &etm->queues.queue_array[i].head, list)
if (buf->reference == event->reference)
cs_etm__dump_event(etm->queues.queue_array[i].priv, buf);
}
static int cs_etm__process_auxtrace_event(struct perf_session *session,
union perf_event *event,
const struct perf_tool *tool __maybe_unused)
{
struct cs_etm_auxtrace *etm = container_of(session->auxtrace,
struct cs_etm_auxtrace,
auxtrace);
if (!etm->data_queued) {
struct auxtrace_buffer *buffer;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/coresight-pmu.h`, `linux/err.h`, `linux/log2.h`, `linux/types.h`, `linux/zalloc.h`, `stdlib.h`.
- Detected declarations: `struct cs_etm_auxtrace`, `struct cs_etm_traceid_queue`, `struct cs_etm_queue`, `struct dummy_branch_stack`, `enum cs_etm_format`, `function cs_etm__get_v7_protocol_version`, `function cs_etm__get_magic`, `function cs_etm__get_cpu`, `function cs_etm__init_pid_fmt`, `function cs_etm__get_pid_fmt`.
- 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.