tools/perf/arch/x86/util/event.c
Source file repositories/reference/linux-study-clean/tools/perf/arch/x86/util/event.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/arch/x86/util/event.c- Extension
.c- Size
- 2343 bytes
- Lines
- 94
- 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/types.hlinux/string.hlinux/zalloc.hstdlib.h../../../util/event.h../../../util/synthetic-events.h../../../util/machine.h../../../util/tool.h../../../util/map.h../../../util/debug.hutil/sample.h
Detected Declarations
struct perf_event__synthesize_extra_kmaps_cb_argsfunction perf_event__synthesize_extra_kmaps_cbfunction perf_event__synthesize_extra_kmaps
Annotated Snippet
struct perf_event__synthesize_extra_kmaps_cb_args {
const struct perf_tool *tool;
perf_event__handler_t process;
struct machine *machine;
union perf_event *event;
};
static int perf_event__synthesize_extra_kmaps_cb(struct map *map, void *data)
{
struct perf_event__synthesize_extra_kmaps_cb_args *args = data;
union perf_event *event = args->event;
struct kmap *kmap;
size_t size;
if (!__map__is_extra_kernel_map(map))
return 0;
kmap = map__kmap(map);
size = sizeof(event->mmap) - sizeof(event->mmap.filename) +
PERF_ALIGN(strlen(kmap->name) + 1, sizeof(u64)) +
args->machine->id_hdr_size;
memset(event, 0, size);
event->mmap.header.type = PERF_RECORD_MMAP;
/*
* kernel uses 0 for user space maps, see kernel/perf_event.c
* __perf_event_mmap
*/
if (machine__is_host(args->machine))
event->header.misc = PERF_RECORD_MISC_KERNEL;
else
event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL;
event->mmap.header.size = size;
event->mmap.start = map__start(map);
event->mmap.len = map__size(map);
event->mmap.pgoff = map__pgoff(map);
event->mmap.pid = args->machine->pid;
strlcpy(event->mmap.filename, kmap->name, PATH_MAX);
if (perf_tool__process_synth_event(args->tool, event, args->machine, args->process) != 0)
return -1;
return 0;
}
int perf_event__synthesize_extra_kmaps(const struct perf_tool *tool,
perf_event__handler_t process,
struct machine *machine)
{
int rc;
struct maps *kmaps = machine__kernel_maps(machine);
struct perf_event__synthesize_extra_kmaps_cb_args args = {
.tool = tool,
.process = process,
.machine = machine,
.event = zalloc(sizeof(args.event->mmap) + machine->id_hdr_size),
};
if (!args.event) {
pr_debug("Not enough memory synthesizing mmap event "
"for extra kernel maps\n");
return -1;
}
rc = maps__for_each_map(kmaps, perf_event__synthesize_extra_kmaps_cb, &args);
free(args.event);
return rc;
}
#endif
Annotation
- Immediate include surface: `linux/types.h`, `linux/string.h`, `linux/zalloc.h`, `stdlib.h`, `../../../util/event.h`, `../../../util/synthetic-events.h`, `../../../util/machine.h`, `../../../util/tool.h`.
- Detected declarations: `struct perf_event__synthesize_extra_kmaps_cb_args`, `function perf_event__synthesize_extra_kmaps_cb`, `function perf_event__synthesize_extra_kmaps`.
- 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.