tools/perf/arch/arm/util/cs-etm.c
Source file repositories/reference/linux-study-clean/tools/perf/arch/arm/util/cs-etm.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/arch/arm/util/cs-etm.c- Extension
.c- Size
- 28272 bytes
- Lines
- 925
- 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
api/fs/fs.hlinux/bits.hlinux/bitops.hlinux/compiler.hlinux/coresight-pmu.hlinux/kernel.hlinux/log2.hlinux/string.hlinux/types.hlinux/zalloc.hcs-etm.h../../../util/debug.h../../../util/record.h../../../util/auxtrace.h../../../util/cpumap.h../../../util/event.h../../../util/evlist.h../../../util/evsel.h../../../util/perf_api_probe.h../../../util/evsel_config.h../../../util/pmus.h../../../util/cs-etm.hinternal/lib.h../../../util/session.herrno.hstdlib.hsys/stat.h
Detected Declarations
struct cs_etm_recordingenum cs_etm_versionfunction cs_etm_get_versionfunction cs_etm_validate_context_idfunction cs_etm_validate_timestampfunction cs_etm_validate_configfunction perf_cpu_map__for_each_cpu_skip_anyfunction cs_etm_parse_snapshot_optionsfunction cs_etm_set_sink_attrfunction list_for_each_entryfunction evlist__for_each_entryfunction cs_etm_recording_optionsfunction evlist__for_each_entryfunction cs_etm_synth_etmcrfunction cs_etmv4_synth_trcconfigrfunction cs_etm_info_priv_sizefunction cs_etm_get_rofunction cs_etm_get_ro_signedfunction cs_etm_pmu_path_existsfunction cs_etm_is_etefunction cs_etm_get_legacy_trace_idfunction cs_etm_save_etmv4_headerfunction cs_etm_get_ro_signedfunction cs_etm_save_ete_headerfunction cs_etm_get_ro_signedfunction cs_etm_get_metadatafunction cs_etm_info_fillfunction perf_cpu_map__for_each_cpufunction perf_cpu_map__for_each_cpufunction cs_etm_snapshot_startfunction cs_etm_snapshot_finishfunction evlist__for_each_entryfunction cs_etm_referencefunction cs_etm_recording_freefunction cs_etm_get_default_config
Annotated Snippet
struct cs_etm_recording {
struct auxtrace_record itr;
struct perf_pmu *cs_etm_pmu;
struct evlist *evlist;
bool snapshot_mode;
size_t snapshot_size;
};
static const char *metadata_etmv3_ro[CS_ETM_PRIV_MAX] = {
[CS_ETM_ETMCCER] = "mgmt/etmccer",
[CS_ETM_ETMIDR] = "mgmt/etmidr",
};
static const char * const metadata_etmv4_ro[] = {
[CS_ETMV4_TRCIDR0] = "trcidr/trcidr0",
[CS_ETMV4_TRCIDR1] = "trcidr/trcidr1",
[CS_ETMV4_TRCIDR2] = "trcidr/trcidr2",
[CS_ETMV4_TRCIDR8] = "trcidr/trcidr8",
[CS_ETMV4_TRCAUTHSTATUS] = "mgmt/trcauthstatus",
[CS_ETMV4_TS_SOURCE] = "ts_source",
};
static const char * const metadata_ete_ro[] = {
[CS_ETE_TRCIDR0] = "trcidr/trcidr0",
[CS_ETE_TRCIDR1] = "trcidr/trcidr1",
[CS_ETE_TRCIDR2] = "trcidr/trcidr2",
[CS_ETE_TRCIDR8] = "trcidr/trcidr8",
[CS_ETE_TRCAUTHSTATUS] = "mgmt/trcauthstatus",
[CS_ETE_TRCDEVARCH] = "mgmt/trcdevarch",
[CS_ETE_TS_SOURCE] = "ts_source",
};
enum cs_etm_version { CS_NOT_PRESENT, CS_ETMV3, CS_ETMV4, CS_ETE };
static bool cs_etm_is_ete(struct perf_pmu *cs_etm_pmu, struct perf_cpu cpu);
static int cs_etm_get_ro(struct perf_pmu *pmu, struct perf_cpu cpu, const char *path, __u64 *val);
static bool cs_etm_pmu_path_exists(struct perf_pmu *pmu, struct perf_cpu cpu, const char *path);
static enum cs_etm_version cs_etm_get_version(struct perf_pmu *cs_etm_pmu,
struct perf_cpu cpu)
{
if (cs_etm_is_ete(cs_etm_pmu, cpu))
return CS_ETE;
else if (cs_etm_pmu_path_exists(cs_etm_pmu, cpu, metadata_etmv4_ro[CS_ETMV4_TRCIDR0]))
return CS_ETMV4;
else if (cs_etm_pmu_path_exists(cs_etm_pmu, cpu, metadata_etmv3_ro[CS_ETM_ETMCCER]))
return CS_ETMV3;
return CS_NOT_PRESENT;
}
static int cs_etm_validate_context_id(struct perf_pmu *cs_etm_pmu, struct evsel *evsel,
struct perf_cpu cpu)
{
int err;
u64 ctxt, ctxt1, ctxt2;
__u64 trcidr2;
evsel__get_config_val(evsel, "contextid", &ctxt);
evsel__get_config_val(evsel, "contextid1", &ctxt1);
evsel__get_config_val(evsel, "contextid2", &ctxt2);
if (!ctxt && !ctxt1 && !ctxt2)
return 0;
/* Not supported in etmv3 */
if (cs_etm_get_version(cs_etm_pmu, cpu) == CS_ETMV3) {
pr_err("%s: contextid not supported in ETMv3, disable with %s/contextid=0/\n",
CORESIGHT_ETM_PMU_NAME, CORESIGHT_ETM_PMU_NAME);
return -EINVAL;
}
/* Get a handle on TRCIDR2 */
err = cs_etm_get_ro(cs_etm_pmu, cpu, metadata_etmv4_ro[CS_ETMV4_TRCIDR2], &trcidr2);
if (err)
return err;
if (ctxt1) {
/*
* TRCIDR2.CIDSIZE, bit [9-5], indicates whether contextID
* tracing is supported:
* 0b00000 Context ID tracing is not supported.
* 0b00100 Maximum of 32-bit Context ID size.
* All other values are reserved.
*/
if (BMVAL(trcidr2, 5, 9) != 0x4) {
pr_err("%s: CONTEXTIDR_EL1 isn't supported, disable with %s/contextid1=0/\n",
CORESIGHT_ETM_PMU_NAME, CORESIGHT_ETM_PMU_NAME);
return -EINVAL;
}
Annotation
- Immediate include surface: `api/fs/fs.h`, `linux/bits.h`, `linux/bitops.h`, `linux/compiler.h`, `linux/coresight-pmu.h`, `linux/kernel.h`, `linux/log2.h`, `linux/string.h`.
- Detected declarations: `struct cs_etm_recording`, `enum cs_etm_version`, `function cs_etm_get_version`, `function cs_etm_validate_context_id`, `function cs_etm_validate_timestamp`, `function cs_etm_validate_config`, `function perf_cpu_map__for_each_cpu_skip_any`, `function cs_etm_parse_snapshot_options`, `function cs_etm_set_sink_attr`, `function list_for_each_entry`.
- 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.