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

Configure Feed

Select the types of activity you want to include in your feed.

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>

+20 -6
+12
tools/testing/selftests/bpf/bpf_arena_spin_lock.h tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h
··· 32 32 struct __qspinlock { 33 33 union { 34 34 atomic_t val; 35 + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 35 36 struct { 36 37 u8 locked; 37 38 u8 pending; ··· 41 40 u16 locked_pending; 42 41 u16 tail; 43 42 }; 43 + #else 44 + struct { 45 + u16 tail; 46 + u16 locked_pending; 47 + }; 48 + struct { 49 + u8 reserved[2]; 50 + u8 pending; 51 + u8 locked; 52 + }; 53 + #endif 44 54 }; 45 55 }; 46 56
+8 -6
tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c
··· 51 51 struct arena_spin_lock *skel; 52 52 pthread_t thread_id[16]; 53 53 int prog_fd, i, err; 54 + int nthreads; 54 55 void *ret; 55 56 56 - if (get_nprocs() < 2) { 57 + nthreads = MIN(get_nprocs(), ARRAY_SIZE(thread_id)); 58 + if (nthreads < 2) { 57 59 test__skip(); 58 60 return; 59 61 } ··· 68 66 goto end; 69 67 } 70 68 skel->bss->cs_count = size; 71 - skel->bss->limit = repeat * 16; 69 + skel->bss->limit = repeat * nthreads; 72 70 73 - ASSERT_OK(pthread_barrier_init(&barrier, NULL, 16), "barrier init"); 71 + ASSERT_OK(pthread_barrier_init(&barrier, NULL, nthreads), "barrier init"); 74 72 75 73 prog_fd = bpf_program__fd(skel->progs.prog); 76 - for (i = 0; i < 16; i++) { 74 + for (i = 0; i < nthreads; i++) { 77 75 err = pthread_create(&thread_id[i], NULL, &spin_lock_thread, &prog_fd); 78 76 if (!ASSERT_OK(err, "pthread_create")) 79 77 goto end_barrier; 80 78 } 81 79 82 - for (i = 0; i < 16; i++) { 80 + for (i = 0; i < nthreads; i++) { 83 81 if (!ASSERT_OK(pthread_join(thread_id[i], &ret), "pthread_join")) 84 82 goto end_barrier; 85 83 if (!ASSERT_EQ(ret, &prog_fd, "ret == prog_fd")) 86 84 goto end_barrier; 87 85 } 88 86 89 - ASSERT_EQ(skel->bss->counter, repeat * 16, "check counter value"); 87 + ASSERT_EQ(skel->bss->counter, repeat * nthreads, "check counter value"); 90 88 91 89 end_barrier: 92 90 pthread_barrier_destroy(&barrier);