tools/perf/pmu-events/jevents.py
Source file repositories/reference/linux-study-clean/tools/perf/pmu-events/jevents.py
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/pmu-events/jevents.py- Extension
.py- Size
- 50491 bytes
- Lines
- 1482
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
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
pmu-events/pmu-events.hutil/header.hutil/pmu.hstring.hstddef.h
Detected Declarations
struct pmu_events_tablestruct pmu_metrics_tablestruct pmu_events_mapstruct pmu_sys_eventsstruct compact_pmu_eventstruct pmu_table_entryfunction decompress_eventfunction decompress_metricfunction pmu_events_table__for_each_event_pmufunction pmu_events_table__find_event_pmufunction pmu_events_table__for_each_eventfunction pmu_events_table__find_eventfunction pmu_events_table__num_eventsfunction pmu_metrics_table__for_each_metric_pmufunction pmu_metrics_table__find_metric_pmufunction pmu_metrics_table__for_each_metricfunction pmu_metrics_table__find_metricfunction pmu_for_each_core_eventfunction pmu_for_each_core_metricfunction pmu_for_each_sys_eventfunction pmu_for_each_sys_metric
Annotated Snippet
struct pmu_events_table {
const struct pmu_table_entry *pmus;
uint32_t num_pmus;
};
/* Struct used to make the PMU metric table implementation opaque to callers. */
struct pmu_metrics_table {
const struct pmu_table_entry *pmus;
uint32_t num_pmus;
};
/*
* Map a CPU to its table of PMU events. The CPU is identified by the
* cpuid field, which is an arch-specific identifier for the CPU.
* The identifier specified in tools/perf/pmu-events/arch/xxx/mapfile
* must match the get_cpuid_str() in tools/perf/arch/xxx/util/header.c)
*
* The cpuid can contain any character other than the comma.
*/
struct pmu_events_map {
const char *arch;
const char *cpuid;
struct pmu_events_table event_table;
struct pmu_metrics_table metric_table;
};
/*
* Global table mapping each known CPU for the architecture to its
* table of PMU events.
*/
static const struct pmu_events_map pmu_events_map[] = {
""")
for arch in archs:
if arch == 'test':
_args.output_file.write("""{
\t.arch = "testarch",
\t.cpuid = "testcpu",
\t.event_table = {
\t\t.pmus = pmu_events__test_soc_cpu,
\t\t.num_pmus = ARRAY_SIZE(pmu_events__test_soc_cpu),
\t},
\t.metric_table = {
\t\t.pmus = pmu_metrics__test_soc_cpu,
\t\t.num_pmus = ARRAY_SIZE(pmu_metrics__test_soc_cpu),
\t}
},
""")
elif arch == 'common':
_args.output_file.write("""{
\t.arch = "common",
\t.cpuid = "common",
\t.event_table = {
\t\t.pmus = pmu_events__common,
\t\t.num_pmus = ARRAY_SIZE(pmu_events__common),
\t},
\t.metric_table = {
\t\t.pmus = pmu_metrics__common,
\t\t.num_pmus = ARRAY_SIZE(pmu_metrics__common),
\t},
},
""")
else:
with open(f'{_args.starting_dir}/{arch}/mapfile.csv') as csvfile:
table = csv.reader(csvfile)
first = True
for row in table:
# Skip the first row or any row beginning with #.
if not first and len(row) > 0 and not row[0].startswith('#'):
event_tblname = file_name_to_table_name('pmu_events_', [], row[2].replace('/', '_'))
if event_tblname in _event_tables:
Annotation
- Immediate include surface: `pmu-events/pmu-events.h`, `util/header.h`, `util/pmu.h`, `string.h`, `stddef.h`.
- Detected declarations: `struct pmu_events_table`, `struct pmu_metrics_table`, `struct pmu_events_map`, `struct pmu_sys_events`, `struct compact_pmu_event`, `struct pmu_table_entry`, `function decompress_event`, `function decompress_metric`, `function pmu_events_table__for_each_event_pmu`, `function pmu_events_table__find_event_pmu`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
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.