1 // SPDX-License-Identifier: GPL-2.0-only
3 * vdso_test_getcpu.c: Sample code to test parse_vdso.c and vDSO getcpu()
5 * Copyright (c) 2020 Arm Ltd
14 #include "../kselftest.h"
15 #include "parse_vdso.h"
18 const char *version = "LINUX_4.15";
20 const char *version = "LINUX_2.6";
22 const char *name = "__vdso_getcpu";
25 typedef long (*getcpu_t)(unsigned int *, unsigned int *,
26 struct getcpu_cache *);
28 int main(int argc, char **argv)
30 unsigned long sysinfo_ehdr;
31 unsigned int cpu, node;
35 sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
37 printf("AT_SYSINFO_EHDR is not present!\n");
41 vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR));
43 get_cpu = (getcpu_t)vdso_sym(version, name);
45 printf("Could not find %s\n", name);
49 ret = get_cpu(&cpu, &node, 0);
51 printf("Running on CPU %u node %u\n", cpu, node);
53 printf("%s failed\n", name);