tools/perf/pmu-events/make_legacy_cache.py
Source file repositories/reference/linux-study-clean/tools/perf/pmu-events/make_legacy_cache.py
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/pmu-events/make_legacy_cache.py- Extension
.py- Size
- 4382 bytes
- Lines
- 130
- 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.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/usr/bin/env python3
# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
import json
hw_cache_id = [
(0, # PERF_COUNT_HW_CACHE_L1D
["L1-dcache", "l1-d", "l1d", "L1-data",],
[0, 1, 2,], # read, write, prefetch
"Level 1 data cache",
),
(1, # PERF_COUNT_HW_CACHE_L1I
["L1-icache", "l1-i", "l1i", "L1-instruction",],
[0, 2,], # read, prefetch
"Level 1 instruction cache",
),
(2, # PERF_COUNT_HW_CACHE_LL
["LLC", "L2"],
[0, 1, 2,], # read, write, prefetch
"Last level cache",
),
(3, # PERF_COUNT_HW_CACHE_DTLB
["dTLB", "d-tlb", "Data-TLB",],
[0, 1, 2,], # read, write, prefetch
"Data TLB",
),
(4, # PERF_COUNT_HW_CACHE_ITLB
["iTLB", "i-tlb", "Instruction-TLB",],
[0,], # read
"Instruction TLB",
),
(5, # PERF_COUNT_HW_CACHE_BPU
["branch", "branches", "bpu", "btb", "bpc",],
[0,], # read
"Branch prediction unit",
),
(6, # PERF_COUNT_HW_CACHE_NODE
["node",],
[0, 1, 2,], # read, write, prefetch
"Local memory",
),
]
hw_cache_op = [
(0, # PERF_COUNT_HW_CACHE_OP_READ
["load", "loads", "read",],
"read"),
(1, # PERF_COUNT_HW_CACHE_OP_WRITE
["store", "stores", "write",],
"write"),
(2, # PERF_COUNT_HW_CACHE_OP_PREFETCH
["prefetch", "prefetches", "speculative-read", "speculative-load",],
"prefetch"),
]
hw_cache_result = [
(0, # PERF_COUNT_HW_CACHE_RESULT_ACCESS
["refs", "Reference", "ops", "access",],
"accesses"),
(1, # PERF_COUNT_HW_CACHE_RESULT_MISS
["misses", "miss",],
"misses"),
]
events = []
def add_event(name: str,
cache_id: int, cache_op: int, cache_result: int,
desc: str,
deprecated: bool) -> None:
# Avoid conflicts with PERF_TYPE_HARDWARE events which are higher priority.
if name in ["branch-misses", "branches"]:
Annotation
- 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.