Merge branch 'selftests-bpf-fix-a-few-issues-in-arena_spin_lock'

Ilya Leoshkevich says:

====================
I tried running the arena_spin_lock test on s390x and ran into the
following issues:

* Changing the header file does not lead to rebuilding the test.
* The checked for number of CPUs and the actually required number of
  CPUs are different.
* Endianness issue in spinlock definition.

This series fixes all three.
====================

Link: https://patch.msgid.link/20250424165525.154403-1-iii@linux.ibm.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
Alexei Starovoitov 2025-04-24 17:24:28 -07:00
commit 46eb012611
2 changed files with 20 additions and 6 deletions

View File

@ -51,9 +51,11 @@ static void test_arena_spin_lock_size(int size)
struct arena_spin_lock *skel;
pthread_t thread_id[16];
int prog_fd, i, err;
int nthreads;
void *ret;
if (get_nprocs() < 2) {
nthreads = MIN(get_nprocs(), ARRAY_SIZE(thread_id));
if (nthreads < 2) {
test__skip();
return;
}
@ -66,25 +68,25 @@ static void test_arena_spin_lock_size(int size)
goto end;
}
skel->bss->cs_count = size;
skel->bss->limit = repeat * 16;
skel->bss->limit = repeat * nthreads;
ASSERT_OK(pthread_barrier_init(&barrier, NULL, 16), "barrier init");
ASSERT_OK(pthread_barrier_init(&barrier, NULL, nthreads), "barrier init");
prog_fd = bpf_program__fd(skel->progs.prog);
for (i = 0; i < 16; i++) {
for (i = 0; i < nthreads; i++) {
err = pthread_create(&thread_id[i], NULL, &spin_lock_thread, &prog_fd);
if (!ASSERT_OK(err, "pthread_create"))
goto end_barrier;
}
for (i = 0; i < 16; i++) {
for (i = 0; i < nthreads; i++) {
if (!ASSERT_OK(pthread_join(thread_id[i], &ret), "pthread_join"))
goto end_barrier;
if (!ASSERT_EQ(ret, &prog_fd, "ret == prog_fd"))
goto end_barrier;
}
ASSERT_EQ(skel->bss->counter, repeat * 16, "check counter value");
ASSERT_EQ(skel->bss->counter, repeat * nthreads, "check counter value");
end_barrier:
pthread_barrier_destroy(&barrier);

View File

@ -32,6 +32,7 @@ extern unsigned long CONFIG_NR_CPUS __kconfig;
struct __qspinlock {
union {
atomic_t val;
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
struct {
u8 locked;
u8 pending;
@ -40,6 +41,17 @@ struct __qspinlock {
u16 locked_pending;
u16 tail;
};
#else
struct {
u16 tail;
u16 locked_pending;
};
struct {
u8 reserved[2];
u8 pending;
u8 locked;
};
#endif
};
};