Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <venkat88@linux.ibm.com>
Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
Link: https://lore.kernel.org/r/20250913091337.1841916-1-skb99@linux.ibm.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Saket Kumar Bhaskar and committed by
Alexei Starovoitov
a9d4e9f0 f7528e44

+17 -1
+13
tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c
··· 40 40 41 41 err = bpf_prog_test_run_opts(prog_fd, &topts); 42 42 ASSERT_OK(err, "test_run err"); 43 + 44 + if (topts.retval == -EOPNOTSUPP) 45 + goto end; 46 + 43 47 ASSERT_EQ((int)topts.retval, 0, "test_run retval"); 44 48 49 + end: 45 50 pthread_exit(arg); 46 51 } 47 52 ··· 68 63 skel = arena_spin_lock__open_and_load(); 69 64 if (!ASSERT_OK_PTR(skel, "arena_spin_lock__open_and_load")) 70 65 return; 66 + 71 67 if (skel->data->test_skip == 2) { 72 68 test__skip(); 73 69 goto end; ··· 90 84 goto end_barrier; 91 85 if (!ASSERT_EQ(ret, &prog_fd, "ret == prog_fd")) 92 86 goto end_barrier; 87 + } 88 + 89 + if (skel->data->test_skip == 3) { 90 + printf("%s:SKIP: CONFIG_NR_CPUS exceed the maximum supported by arena spinlock\n", 91 + __func__); 92 + test__skip(); 93 + goto end_barrier; 93 94 } 94 95 95 96 ASSERT_EQ(skel->bss->counter, repeat * nthreads, "check counter value");
+4 -1
tools/testing/selftests/bpf/progs/arena_spin_lock.c
··· 37 37 #if defined(ENABLE_ATOMICS_TESTS) && defined(__BPF_FEATURE_ADDR_SPACE_CAST) 38 38 unsigned long flags; 39 39 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; 41 43 return ret; 44 + } 42 45 if (counter != limit) 43 46 counter++; 44 47 bpf_repeat(cs_count);