[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aLlrOFzwRZotcpY4@linux.ibm.com>
Date: Thu, 4 Sep 2025 16:04:32 +0530
From: Saket Kumar Bhaskar <skb99@...ux.ibm.com>
To: Hari Bathini <hbathini@...ux.ibm.com>
Cc: bpf@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
sachinpb@...ux.ibm.com, venkat88@...ux.ibm.com, andrii@...nel.org,
eddyz87@...il.com, mykolal@...com, ast@...nel.org,
daniel@...earbox.net, martin.lau@...ux.dev, song@...nel.org,
yonghong.song@...ux.dev, john.fastabend@...il.com, kpsingh@...nel.org,
sdf@...ichev.me, haoluo@...gle.com, jolsa@...nel.org,
christophe.leroy@...roup.eu, naveen@...nel.org, maddy@...ux.ibm.com,
mpe@...erman.id.au, npiggin@...il.com, memxor@...il.com,
iii@...ux.ibm.com, shuah@...nel.org
Subject: Re: [PATCH bpf-next v2 5/5] selftests/bpf: Fix arena_spin_lock
selftest failure
On Thu, Sep 04, 2025 at 01:55:40PM +0530, Saket Kumar Bhaskar wrote:
> On Thu, Sep 04, 2025 at 01:39:31PM +0530, Hari Bathini wrote:
> >
> >
> > On 29/08/25 10:21 pm, Saket Kumar Bhaskar wrote:
> > > For systems having CONFIG_NR_CPUS set to > 1024 in kernel config
> > > the selftest fails as arena_spin_lock_irqsave() returns EOPNOTSUPP.
> > >
> > > The selftest is skipped incase bpf program returns EOPNOTSUPP,
> > > with a descriptive message logged.
> > >
> > > Signed-off-by: Saket Kumar Bhaskar <skb99@...ux.ibm.com>
> > > ---
> > > .../selftests/bpf/prog_tests/arena_spin_lock.c | 13 +++++++++++++
> > > tools/testing/selftests/bpf/progs/arena_spin_lock.c | 5 ++++-
> > > 2 files changed, 17 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c b/tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c
> > > index 0223fce4db2b..1ec1ca987893 100644
> > > --- a/tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c
> > > +++ b/tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c
> > > @@ -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 == 2) {
> > > + printf("%s:SKIP: %d CPUs exceed the maximum supported by arena spinlock\n",
> > > + __func__, get_nprocs());
> > > + test__skip();
> > > + goto end_barrier;
> > > + }
> > > +
> > > ASSERT_EQ(skel->bss->counter, repeat * nthreads, "check counter value");
> > > end_barrier:
> > > diff --git a/tools/testing/selftests/bpf/progs/arena_spin_lock.c b/tools/testing/selftests/bpf/progs/arena_spin_lock.c
> > > index c4500c37f85e..a475b974438e 100644
> > > --- a/tools/testing/selftests/bpf/progs/arena_spin_lock.c
> > > +++ b/tools/testing/selftests/bpf/progs/arena_spin_lock.c
> > > @@ -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 = 2;
> > > return ret;
> >
> > test_skip being set to `1` when the test runs seems counter intuitive.
> > How about setting test_skip to `0` when run conditions are met
> > and test_skip=1 if run conditions are not met and
> > test_skip=2 when operation is not supported?
> >
> > - Hari
> That seems reasonable to me, but right now -EOPNOTSUPP is also
> returned when run condition is not met i.e.:
>
> if (CONFIG_NR_CPUS > 1024)
> return -EOPNOTSUPP;
>
> So do we really need test_skip = 2 ?
>
> Thanks,
> Saket
Also, when test_skip is initialized to 0 it is moved to bss segment
from data segment:
struct arena_spin_lock__arena {
struct arena_qnode qnodes[1024][4];
struct __qspinlock lock;
} *arena;
struct arena_spin_lock__bss {
int test_skip;
int counter;
int limit;
int cs_count;
} *bss;
I dont have enough background here, as to if there is any specific
reason to keep it in data segment:
if (skel->data->test_skip == 2) {
test__skip();
goto end;
}
Thanks,
Saket
Powered by blists - more mailing lists