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"
17 const char *version
= "LINUX_2.6";
18 const char *name
= "__vdso_getcpu";
21 typedef long (*getcpu_t
)(unsigned int *, unsigned int *,
22 struct getcpu_cache
*);
24 int main(int argc
, char **argv
)
26 unsigned long sysinfo_ehdr
;
27 unsigned int cpu
, node
;
31 sysinfo_ehdr
= getauxval(AT_SYSINFO_EHDR
);
33 printf("AT_SYSINFO_EHDR is not present!\n");
37 vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR
));
39 get_cpu
= (getcpu_t
)vdso_sym(version
, name
);
41 printf("Could not find %s\n", name
);
45 ret
= get_cpu(&cpu
, &node
, 0);
47 printf("Running on CPU %u node %u\n", cpu
, node
);
49 printf("%s failed\n", name
);