]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests/bpf: Fix arena_spin_lock selftest failure
authorSaket Kumar Bhaskar <skb99@linux.ibm.com>
Sat, 13 Sep 2025 09:13:37 +0000 (14:43 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 15 Sep 2025 17:49:18 +0000 (10:49 -0700)
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>
tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c
tools/testing/selftests/bpf/progs/arena_spin_lock.c

index 0223fce4db2bc260e93f1066563c0db31d38bfa6..693fd86fbde622f90c00a166e4871070875e356b 100644 (file)
@@ -40,8 +40,13 @@ static void *spin_lock_thread(void *arg)
 
        err = bpf_prog_test_run_opts(prog_fd, &topts);
        ASSERT_OK(err, "test_run err");
+
+       if (topts.retval == -EOPNOTSUPP)
+               goto end;
+
        ASSERT_EQ((int)topts.retval, 0, "test_run retval");
 
+end:
        pthread_exit(arg);
 }
 
@@ -63,6 +68,7 @@ static void test_arena_spin_lock_size(int size)
        skel = arena_spin_lock__open_and_load();
        if (!ASSERT_OK_PTR(skel, "arena_spin_lock__open_and_load"))
                return;
+
        if (skel->data->test_skip == 2) {
                test__skip();
                goto end;
@@ -86,6 +92,13 @@ static void test_arena_spin_lock_size(int size)
                        goto end_barrier;
        }
 
+       if (skel->data->test_skip == 3) {
+               printf("%s:SKIP: CONFIG_NR_CPUS exceed the maximum supported by arena spinlock\n",
+                      __func__);
+               test__skip();
+               goto end_barrier;
+       }
+
        ASSERT_EQ(skel->bss->counter, repeat * nthreads, "check counter value");
 
 end_barrier:
index c4500c37f85e06b5819d45ecdc8e94e875c97875..086b57a426cf5ae999351d1a70d6741eca58009d 100644 (file)
@@ -37,8 +37,11 @@ int prog(void *ctx)
 #if defined(ENABLE_ATOMICS_TESTS) && defined(__BPF_FEATURE_ADDR_SPACE_CAST)
        unsigned long flags;
 
-       if ((ret = arena_spin_lock_irqsave(&lock, flags)))
+       if ((ret = arena_spin_lock_irqsave(&lock, flags))) {
+               if (ret == -EOPNOTSUPP)
+                       test_skip = 3;
                return ret;
+       }
        if (counter != limit)
                counter++;
        bpf_repeat(cs_count);