Skip to content

Commit 90a1ded

Browse files
iii-iAlexei Starovoitov
authored andcommitted
selftests/bpf: Fix test_ksyms on non-SMP kernels
On non-SMP kernels __per_cpu_start is not 0, so look it up in kallsyms. Signed-off-by: Ilya Leoshkevich <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent d66423f commit 90a1ded

File tree

1 file changed

+4
-2
lines changed
  • tools/testing/selftests/bpf/prog_tests

1 file changed

+4
-2
lines changed

tools/testing/selftests/bpf/prog_tests/ksyms.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ static __u64 kallsyms_find(const char *sym)
3232

3333
void test_ksyms(void)
3434
{
35+
__u64 per_cpu_start_addr = kallsyms_find("__per_cpu_start");
3536
__u64 link_fops_addr = kallsyms_find("bpf_link_fops");
3637
const char *btf_path = "/sys/kernel/btf/vmlinux";
3738
struct test_ksyms *skel;
@@ -63,8 +64,9 @@ void test_ksyms(void)
6364
"got %llu, exp %llu\n", data->out__bpf_link_fops1, (__u64)0);
6465
CHECK(data->out__btf_size != btf_size, "btf_size",
6566
"got %llu, exp %llu\n", data->out__btf_size, btf_size);
66-
CHECK(data->out__per_cpu_start != 0, "__per_cpu_start",
67-
"got %llu, exp %llu\n", data->out__per_cpu_start, (__u64)0);
67+
CHECK(data->out__per_cpu_start != per_cpu_start_addr, "__per_cpu_start",
68+
"got %llu, exp %llu\n", data->out__per_cpu_start,
69+
per_cpu_start_addr);
6870

6971
cleanup:
7072
test_ksyms__destroy(skel);

0 commit comments

Comments
 (0)