tools/testing/selftests/vDSO/vdso_test_getcpu.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/vDSO/vdso_test_getcpu.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/vDSO/vdso_test_getcpu.c- Extension
.c- Size
- 1166 bytes
- Lines
- 54
- 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.
Dependency Surface
stdint.helf.hstdio.hsys/auxv.hsys/time.hkselftest.hparse_vdso.hvdso_config.hvdso_call.h
Detected Declarations
function main
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* vdso_test_getcpu.c: Sample code to test parse_vdso.c and vDSO getcpu()
*
* Copyright (c) 2020 Arm Ltd
*/
#include <stdint.h>
#include <elf.h>
#include <stdio.h>
#include <sys/auxv.h>
#include <sys/time.h>
#include "kselftest.h"
#include "parse_vdso.h"
#include "vdso_config.h"
#include "vdso_call.h"
typedef long (*getcpu_t)(unsigned int *, unsigned int *, void *);
int main(int argc, char **argv)
{
const char *version = versions[VDSO_VERSION];
const char **name = (const char **)&names[VDSO_NAMES];
unsigned long sysinfo_ehdr;
unsigned int cpu, node;
getcpu_t get_cpu;
long ret;
sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
if (!sysinfo_ehdr) {
printf("AT_SYSINFO_EHDR is not present!\n");
return KSFT_SKIP;
}
vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR));
get_cpu = (getcpu_t)vdso_sym(version, name[4]);
if (!get_cpu) {
printf("Could not find %s\n", name[4]);
return KSFT_SKIP;
}
ret = VDSO_CALL(get_cpu, 3, &cpu, &node, 0);
if (ret == 0) {
printf("Running on CPU %u node %u\n", cpu, node);
} else {
printf("%s failed\n", name[4]);
return KSFT_FAIL;
}
return 0;
}
Annotation
- Immediate include surface: `stdint.h`, `elf.h`, `stdio.h`, `sys/auxv.h`, `sys/time.h`, `kselftest.h`, `parse_vdso.h`, `vdso_config.h`.
- Detected declarations: `function main`.
- 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.