tools/lib/perf/Documentation/examples/sampling.c
Source file repositories/reference/linux-study-clean/tools/lib/perf/Documentation/examples/sampling.c
File Facts
- System
- Linux kernel
- Corpus path
tools/lib/perf/Documentation/examples/sampling.c- Extension
.c- Size
- 2371 bytes
- Lines
- 120
- 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/perf_event.hperf/evlist.hperf/evsel.hperf/cpumap.hperf/threadmap.hperf/mmap.hperf/core.hperf/event.hstdio.hunistd.h
Detected Declarations
function libperf_printfunction mainfunction perf_evlist__for_each_mmap
Annotated Snippet
while ((event = perf_mmap__read_event(map)) != NULL) {
int cpu, pid, tid;
__u64 ip, period, *array;
union u64_swap u;
array = event->sample.array;
ip = *array;
array++;
u.val64 = *array;
pid = u.val32[0];
tid = u.val32[1];
array++;
u.val64 = *array;
cpu = u.val32[0];
array++;
period = *array;
fprintf(stdout, "cpu %3d, pid %6d, tid %6d, ip %20llx, period %20llu\n",
cpu, pid, tid, ip, period);
perf_mmap__consume(map);
}
perf_mmap__read_done(map);
}
out_evlist:
perf_evlist__delete(evlist);
out_cpus:
perf_cpu_map__put(cpus);
return err;
}
Annotation
- Immediate include surface: `linux/perf_event.h`, `perf/evlist.h`, `perf/evsel.h`, `perf/cpumap.h`, `perf/threadmap.h`, `perf/mmap.h`, `perf/core.h`, `perf/event.h`.
- Detected declarations: `function libperf_print`, `function main`, `function perf_evlist__for_each_mmap`.
- 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.