tools/perf/util/vdso.c
Source file repositories/reference/linux-study-clean/tools/perf/util/vdso.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/vdso.c- Extension
.c- Size
- 7568 bytes
- Lines
- 370
- 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
errno.hunistd.hstdio.hstring.hsys/types.hsys/stat.hfcntl.hstdlib.hlinux/kernel.hvdso.hdso.hinternal/lib.hmap.hsymbol.hmachine.hthread.hlinux/string.hlinux/zalloc.hdebug.hfind-map.c
Detected Declarations
struct vdso_filestruct vdso_infostruct machine__thread_dso_type_maps_cb_argsfunction machine__exit_vdsofunction machine__thread_dso_type_maps_cbfunction machine__thread_dso_typefunction vdso__do_copy_compatfunction vdso__copy_compatfunction vdso__create_compat_filefunction __machine__findnew_vdso_compatfunction dso__is_vdso
Annotated Snippet
struct vdso_file {
bool found;
bool error;
char temp_file_name[sizeof(VDSO__TEMP_FILE_NAME)];
const char *dso_name;
const char *read_prog;
};
struct vdso_info {
struct vdso_file vdso;
#if BITS_PER_LONG == 64
struct vdso_file vdso32;
struct vdso_file vdsox32;
#endif
};
static struct vdso_info *vdso_info__new(void)
{
static const struct vdso_info vdso_info_init = {
.vdso = {
.temp_file_name = VDSO__TEMP_FILE_NAME,
.dso_name = DSO__NAME_VDSO,
},
#if BITS_PER_LONG == 64
.vdso32 = {
.temp_file_name = VDSO__TEMP_FILE_NAME,
.dso_name = DSO__NAME_VDSO32,
.read_prog = "perf-read-vdso32",
},
.vdsox32 = {
.temp_file_name = VDSO__TEMP_FILE_NAME,
.dso_name = DSO__NAME_VDSOX32,
.read_prog = "perf-read-vdsox32",
},
#endif
};
return memdup(&vdso_info_init, sizeof(vdso_info_init));
}
static char *get_file(struct vdso_file *vdso_file)
{
char *vdso = NULL;
char *buf = NULL;
void *start, *end;
size_t size;
int fd;
if (vdso_file->found)
return vdso_file->temp_file_name;
if (vdso_file->error || find_map(&start, &end, VDSO__MAP_NAME))
return NULL;
size = end - start;
buf = memdup(start, size);
if (!buf)
return NULL;
fd = mkstemp(vdso_file->temp_file_name);
if (fd < 0)
goto out;
if (size == (size_t) write(fd, buf, size))
vdso = vdso_file->temp_file_name;
close(fd);
out:
free(buf);
vdso_file->found = (vdso != NULL);
vdso_file->error = !vdso_file->found;
return vdso;
}
void machine__exit_vdso(struct machine *machine)
{
struct vdso_info *vdso_info = machine->vdso_info;
if (!vdso_info)
return;
if (vdso_info->vdso.found)
unlink(vdso_info->vdso.temp_file_name);
#if BITS_PER_LONG == 64
if (vdso_info->vdso32.found)
unlink(vdso_info->vdso32.temp_file_name);
if (vdso_info->vdsox32.found)
Annotation
- Immediate include surface: `errno.h`, `unistd.h`, `stdio.h`, `string.h`, `sys/types.h`, `sys/stat.h`, `fcntl.h`, `stdlib.h`.
- Detected declarations: `struct vdso_file`, `struct vdso_info`, `struct machine__thread_dso_type_maps_cb_args`, `function machine__exit_vdso`, `function machine__thread_dso_type_maps_cb`, `function machine__thread_dso_type`, `function vdso__do_copy_compat`, `function vdso__copy_compat`, `function vdso__create_compat_file`, `function __machine__findnew_vdso_compat`.
- 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.