Skip to content

Commit a9d4e9f

Browse files
Saket Kumar BhaskarAlexei Starovoitov
authored andcommitted
selftests/bpf: Fix arena_spin_lock selftest failure
For systems having CONFIG_NR_CPUS set to > 1024 in kernel config the selftest fails as arena_spin_lock_irqsave() returns EOPNOTSUPP. (eg - incase of powerpc default value for CONFIG_NR_CPUS is 8192) The selftest is skipped incase bpf program returns EOPNOTSUPP, with a descriptive message logged. Tested-by: Venkat Rao Bagalkote <[email protected]> Signed-off-by: Saket Kumar Bhaskar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent f7528e4 commit a9d4e9f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ static void *spin_lock_thread(void *arg)
4040

4141
err = bpf_prog_test_run_opts(prog_fd, &topts);
4242
ASSERT_OK(err, "test_run err");
43+
44+
if (topts.retval == -EOPNOTSUPP)
45+
goto end;
46+
4347
ASSERT_EQ((int)topts.retval, 0, "test_run retval");
4448

49+
end:
4550
pthread_exit(arg);
4651
}
4752

@@ -63,6 +68,7 @@ static void test_arena_spin_lock_size(int size)
6368
skel = arena_spin_lock__open_and_load();
6469
if (!ASSERT_OK_PTR(skel, "arena_spin_lock__open_and_load"))
6570
return;
71+
6672
if (skel->data->test_skip == 2) {
6773
test__skip();
6874
goto end;
@@ -86,6 +92,13 @@ static void test_arena_spin_lock_size(int size)
8692
goto end_barrier;
8793
}
8894

95+
if (skel->data->test_skip == 3) {
96+
printf("%s:SKIP: CONFIG_NR_CPUS exceed the maximum supported by arena spinlock\n",
97+
__func__);
98+
test__skip();
99+
goto end_barrier;
100+
}
101+
89102
ASSERT_EQ(skel->bss->counter, repeat * nthreads, "check counter value");
90103

91104
end_barrier:

tools/testing/selftests/bpf/progs/arena_spin_lock.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ int prog(void *ctx)
3737
#if defined(ENABLE_ATOMICS_TESTS) && defined(__BPF_FEATURE_ADDR_SPACE_CAST)
3838
unsigned long flags;
3939

40-
if ((ret = arena_spin_lock_irqsave(&lock, flags)))
40+
if ((ret = arena_spin_lock_irqsave(&lock, flags))) {
41+
if (ret == -EOPNOTSUPP)
42+
test_skip = 3;
4143
return ret;
44+
}
4245
if (counter != limit)
4346
counter++;
4447
bpf_repeat(cs_count);

0 commit comments

Comments
 (0)