The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch
@ 2026-11-26  5:53 George Guo
  2026-11-26  5:53 ` [PATCH bpf-next v1 1/5] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free George Guo
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: George Guo @ 2026-11-26  5:53 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

From: George Guo <guodongtai@kylinos.cn>

This series enables the BPF selftests for the new LoongArch JIT
features, and fixes a libarena build failure with clang 19.

Patch 1 fixes the build of the libarena buddy allocator selftests with
clang 19, which refuses the signed remainder in test_buddy_alloc_free().

Patches 2-5 enable the following tests for LoongArch:

  - the 2 KiB private stack test in verifier_large_stack
  - the struct_ops private stack tests
  - the arena LDSX tests in verifier_ldsx
  - the arena load-acquire and store-release tests in arena_atomics, and
    the libarena spmc and bitmap parallel tests

The LoongArch JIT support for these features is in the following series,
which goes through the LoongArch tree:

  LoongArch: BPF: Add private stack, exceptions, large stack and arena support
  https://lore.kernel.org/loongarch/20261126034048.7370-1-dongtai.guo@linux.dev/T/#u

These patches were part of v2 of the LoongArch BPF series:
https://lore.kernel.org/loongarch/20260702022322.51033-1-dongtai.guo@linux.dev/

Since then:
  - Split the selftests patches out of the LoongArch series and rebase
    them onto bpf-next.
  - New patch 1: use an unsigned loop counter in test_buddy_alloc_free.
  - New patch 2: enable the 2 KiB private stack test.
  - Patch 5: also enable the libarena spmc test, which has the same
    guard as arena_atomics (Sashiko), and the libarena bitmap test,
    which needs cmpxchg on arena too.
  - Drop "selftests/bpf: Add LoongArch deny list" (Tiezhu).
  - Reword the subjects and commit messages.

George Guo (5):
  selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free
  selftests/bpf: Enable 2 KiB private stack test for LoongArch
  selftests/bpf: Enable struct_ops private stack tests for LoongArch
  selftests/bpf: Enable arena LDSX tests for LoongArch
  selftests/bpf: Enable arena atomics tests for LoongArch

 .../bpf/libarena/selftests/test_buddy.bpf.c     |  3 ++-
 .../selftests/test_parallel_bitmap.bpf.c        |  1 +
 .../libarena/selftests/test_parallel_spmc.bpf.c |  1 +
 .../bpf/prog_tests/struct_ops_private_stack.c   |  3 ++-
 .../testing/selftests/bpf/progs/arena_atomics.c |  3 +++
 .../selftests/bpf/progs/verifier_large_stack.c  |  1 +
 .../testing/selftests/bpf/progs/verifier_ldsx.c | 17 +++++++++++++++++
 7 files changed, 27 insertions(+), 2 deletions(-)


base-commit: 486b5ce7184f7449ef2fe1e951455b0b8a114060
-- 
2.53.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH bpf-next v1 1/5] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free
  2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
@ 2026-11-26  5:53 ` George Guo
  2026-11-26  5:53 ` [PATCH bpf-next v1 2/5] selftests/bpf: Enable 2 KiB private stack test for LoongArch George Guo
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: George Guo @ 2026-11-26  5:53 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

From: George Guo <guodongtai@kylinos.cn>

test_buddy_alloc_free() picks an allocation size with
alloc_free_sizes[(i * 5) % 8], where i is a signed int. That is a
signed remainder, which clang 19 refuses to compile for BPF without
-mcpu=v4:

  test_buddy.bpf.c:80:54: error: unsupported signed division, please convert to unsigned div/mod.

i only counts up from zero, so make it a u32, like the loop counter in
test_buddy_alloc_multiple() and the u32 zero it starts from. The
remainder becomes unsigned and the selected sizes are unchanged.

Fixes: b1487dc1b181 ("selftests/bpf: Add selftests for libarena buddy allocator")
Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
 .../testing/selftests/bpf/libarena/selftests/test_buddy.bpf.c  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_buddy.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_buddy.bpf.c
index 886a09019566..00f1efe931af 100644
--- a/tools/testing/selftests/bpf/libarena/selftests/test_buddy.bpf.c
+++ b/tools/testing/selftests/bpf/libarena/selftests/test_buddy.bpf.c
@@ -99,7 +99,8 @@ __weak int test_buddy_alloc_free(void)
 {
 	const int iters = 800;
 	void __arena *mem;
-	int ret, i;
+	int ret;
+	u32 i;
 
 	ret = buddy_init(&buddy);
 	if (ret)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH bpf-next v1 2/5] selftests/bpf: Enable 2 KiB private stack test for LoongArch
  2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
  2026-11-26  5:53 ` [PATCH bpf-next v1 1/5] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free George Guo
@ 2026-11-26  5:53 ` George Guo
  2026-11-26  5:53 ` [PATCH bpf-next v1 3/5] selftests/bpf: Enable struct_ops private stack tests " George Guo
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: George Guo @ 2026-11-26  5:53 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

From: George Guo <guodongtai@kylinos.cn>

As the LoongArch JIT supports both private stack and large stack, enable
the "private stack: two frames of 2048 bytes" test in
verifier_large_stack for LoongArch.

With this patch:
  $ sudo ./test_progs -a "verifier_large_stack/private stack: two frames of 2048 bytes" | tail -1
  Summary: 1/1 PASSED, 0 SKIPPED, 0/0 FAILED

Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
 tools/testing/selftests/bpf/progs/verifier_large_stack.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/bpf/progs/verifier_large_stack.c b/tools/testing/selftests/bpf/progs/verifier_large_stack.c
index cbabb41d973c..f25455d628d5 100644
--- a/tools/testing/selftests/bpf/progs/verifier_large_stack.c
+++ b/tools/testing/selftests/bpf/progs/verifier_large_stack.c
@@ -248,6 +248,7 @@ __description("private stack: two frames of 2048 bytes")
 __load_if_large_stack()
 __arch_x86_64
 __arch_arm64
+__arch_loongarch
 __success __log_level(4)
 __msg("stack depth max 2048")
 __msg("subprog 0 (private_stack_two_frames) main {{.*}} stack 2048")
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH bpf-next v1 3/5] selftests/bpf: Enable struct_ops private stack tests for LoongArch
  2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
  2026-11-26  5:53 ` [PATCH bpf-next v1 1/5] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free George Guo
  2026-11-26  5:53 ` [PATCH bpf-next v1 2/5] selftests/bpf: Enable 2 KiB private stack test for LoongArch George Guo
@ 2026-11-26  5:53 ` George Guo
  2026-11-26  5:53 ` [PATCH bpf-next v1 4/5] selftests/bpf: Enable arena LDSX " George Guo
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: George Guo @ 2026-11-26  5:53 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

From: George Guo <guodongtai@kylinos.cn>

As the LoongArch JIT supports private stack, enable the struct_ops
private stack tests for LoongArch.

With this patch:
  $ sudo ./test_progs -t struct_ops_private_stack | tail -1
  Summary: 1/4 PASSED, 0 SKIPPED, 0/0 FAILED

Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
 .../selftests/bpf/prog_tests/struct_ops_private_stack.c        | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c b/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
index 103179ff8733..730d5741591c 100644
--- a/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
+++ b/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
@@ -7,7 +7,8 @@
 #include "struct_ops_private_stack_large.skel.h"
 
 #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \
-	(defined(__riscv) && __riscv_xlen == 64)
+	(defined(__riscv) && __riscv_xlen == 64) || \
+	(defined(__loongarch__) && __loongarch_grlen == 64)
 static void test_private_stack(void)
 {
 	struct struct_ops_private_stack *skel;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH bpf-next v1 4/5] selftests/bpf: Enable arena LDSX tests for LoongArch
  2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
                   ` (2 preceding siblings ...)
  2026-11-26  5:53 ` [PATCH bpf-next v1 3/5] selftests/bpf: Enable struct_ops private stack tests " George Guo
@ 2026-11-26  5:53 ` George Guo
  2026-11-26  5:53 ` [PATCH bpf-next v1 5/5] selftests/bpf: Enable arena atomics " George Guo
  2026-11-26  6:06 ` [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena " Alexei Starovoitov
  5 siblings, 0 replies; 7+ messages in thread
From: George Guo @ 2026-11-26  5:53 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

From: George Guo <guodongtai@kylinos.cn>

As the LoongArch JIT supports signed arena loads, enable the arena LDSX
tests in verifier_ldsx for LoongArch, and add the expected LoongArch JIT
disassembly for the arena_ldsx_disasm test.

With this patch:
  $ sudo ./test_progs -t verifier_ldsx | tail -1
  Summary: 1/24 PASSED, 0 SKIPPED, 0/0 FAILED

Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
 .../testing/selftests/bpf/progs/verifier_ldsx.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/tools/testing/selftests/bpf/progs/verifier_ldsx.c b/tools/testing/selftests/bpf/progs/verifier_ldsx.c
index 232082428cb9..ad7ae015b39d 100644
--- a/tools/testing/selftests/bpf/progs/verifier_ldsx.c
+++ b/tools/testing/selftests/bpf/progs/verifier_ldsx.c
@@ -299,6 +299,19 @@ __jited("add	t2, a0, s7")
 __jited("lh	s4, 0x18(t2)")
 __jited("add	t2, a0, s7")
 __jited("lb	s4, 0x20(t2)")
+__arch_loongarch
+__jited("add.d	$t2, $a5, $s6")
+__jited("ld.w	$s2, $t2, 16")
+__jited("add.d	$t2, $a5, $s6")
+__jited("ld.h	$s2, $t2, 24")
+__jited("add.d	$t2, $a5, $s6")
+__jited("ld.b	$s2, $t2, 32")
+__jited("add.d	$t2, $a0, $s6")
+__jited("ld.w	$s3, $t2, 16")
+__jited("add.d	$t2, $a0, $s6")
+__jited("ld.h	$s3, $t2, 24")
+__jited("add.d	$t2, $a0, $s6")
+__jited("ld.b	$s3, $t2, 32")
 __naked void arena_ldsx_disasm(void *ctx)
 {
 	asm volatile (
@@ -331,6 +344,7 @@ __success __retval(0)
 __arch_x86_64
 __arch_arm64
 __arch_riscv64
+__arch_loongarch
 __naked void arena_ldsx_exception(void *ctx)
 {
 	asm volatile (
@@ -353,6 +367,7 @@ __success __retval(-1)
 __arch_x86_64
 __arch_arm64
 __arch_riscv64
+__arch_loongarch
 __naked void arena_ldsx_s8(void *ctx)
 {
 	asm volatile (
@@ -385,6 +400,7 @@ __success __retval(-1)
 __arch_x86_64
 __arch_arm64
 __arch_riscv64
+__arch_loongarch
 __naked void arena_ldsx_s16(void *ctx)
 {
 	asm volatile (
@@ -417,6 +433,7 @@ __success __retval(-1)
 __arch_x86_64
 __arch_arm64
 __arch_riscv64
+__arch_loongarch
 __naked void arena_ldsx_s32(void *ctx)
 {
 	asm volatile (
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH bpf-next v1 5/5] selftests/bpf: Enable arena atomics tests for LoongArch
  2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
                   ` (3 preceding siblings ...)
  2026-11-26  5:53 ` [PATCH bpf-next v1 4/5] selftests/bpf: Enable arena LDSX " George Guo
@ 2026-11-26  5:53 ` George Guo
  2026-11-26  6:06 ` [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena " Alexei Starovoitov
  5 siblings, 0 replies; 7+ messages in thread
From: George Guo @ 2026-11-26  5:53 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

From: George Guo <guodongtai@kylinos.cn>

As the LoongArch JIT supports arena atomics, add LoongArch to the
architecture guards of the load-acquire and store-release tests in
arena_atomics, and of the spmc and bitmap parallel tests in libarena,
which use atomics on arena too.

With this patch:
  $ sudo ./test_progs -t arena_atomics | tail -1
  Summary: 1/11 PASSED, 0 SKIPPED, 0/0 FAILED

  $ sudo ./test_progs -t libarena | tail -1
  Summary: 2/43 PASSED, 0 SKIPPED, 0/0 FAILED

Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
 .../bpf/libarena/selftests/test_parallel_bitmap.bpf.c          | 1 +
 .../selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c  | 1 +
 tools/testing/selftests/bpf/progs/arena_atomics.c              | 3 +++
 3 files changed, 5 insertions(+)

diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_bitmap.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_parallel_bitmap.bpf.c
index 017add229bef..722971b1eba8 100644
--- a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_bitmap.bpf.c
+++ b/tools/testing/selftests/bpf/libarena/selftests/test_parallel_bitmap.bpf.c
@@ -24,6 +24,7 @@ static volatile bool test_abort;
 	(defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \
 	 defined(__TARGET_ARCH_s390) || \
 	 defined(__TARGET_ARCH_powerpc) ||				  \
+	 defined(__TARGET_ARCH_loongarch) || \
 	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64))
 static bool bitmap_tests_enabled(void)
 {
diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c
index 5fa96eb74095..af577e1e5050 100644
--- a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c
+++ b/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c
@@ -70,6 +70,7 @@ static volatile u64 round_steals;
  */
 #if defined(ENABLE_ATOMICS_TESTS) &&		  \
 	(defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \
+	 defined(__TARGET_ARCH_loongarch) || \
 	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64))
 static bool spmc_tests_enabled(void)
 {
diff --git a/tools/testing/selftests/bpf/progs/arena_atomics.c b/tools/testing/selftests/bpf/progs/arena_atomics.c
index 2a9664f54399..fcb70b984434 100644
--- a/tools/testing/selftests/bpf/progs/arena_atomics.c
+++ b/tools/testing/selftests/bpf/progs/arena_atomics.c
@@ -30,6 +30,7 @@ bool skip_all_tests = true;
 	defined(__BPF_FEATURE_ADDR_SPACE_CAST) && \
 	(defined(__TARGET_ARCH_arm64) || \
 	 defined(__TARGET_ARCH_x86) || \
+	 defined(__TARGET_ARCH_loongarch) || \
 	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
 	 defined(__TARGET_ARCH_s390))
 bool skip_lacq_srel_tests __attribute((__section__(".data"))) = false;
@@ -454,6 +455,7 @@ int load_acquire(const void *ctx)
 	defined(__BPF_FEATURE_ADDR_SPACE_CAST) && \
 	(defined(__TARGET_ARCH_arm64) || \
 	 defined(__TARGET_ARCH_x86) || \
+	 defined(__TARGET_ARCH_loongarch) || \
 	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
 	 defined(__TARGET_ARCH_s390))
 
@@ -508,6 +510,7 @@ int store_release(const void *ctx)
 	defined(__BPF_FEATURE_ADDR_SPACE_CAST) && \
 	(defined(__TARGET_ARCH_arm64) || \
 	 defined(__TARGET_ARCH_x86) || \
+	 defined(__TARGET_ARCH_loongarch) || \
 	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
 	 defined(__TARGET_ARCH_s390))
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch
  2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
                   ` (4 preceding siblings ...)
  2026-11-26  5:53 ` [PATCH bpf-next v1 5/5] selftests/bpf: Enable arena atomics " George Guo
@ 2026-11-26  6:06 ` Alexei Starovoitov
  5 siblings, 0 replies; 7+ messages in thread
From: Alexei Starovoitov @ 2026-11-26  6:06 UTC (permalink / raw)
  To: George Guo, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

On Wed, Nov 25, 2026 at 09:53 PM George Guo <dongtai.guo@linux.dev> wrote:
> This series enables the BPF selftests for the new LoongArch JIT
> features, and fixes a libarena build failure with clang 19.

loongarch folks take JIT patches, so pls don't post
anything to bpf* until trees converge.

pw-bot: cr

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-26  6:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
2026-11-26  5:53 ` [PATCH bpf-next v1 1/5] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free George Guo
2026-11-26  5:53 ` [PATCH bpf-next v1 2/5] selftests/bpf: Enable 2 KiB private stack test for LoongArch George Guo
2026-11-26  5:53 ` [PATCH bpf-next v1 3/5] selftests/bpf: Enable struct_ops private stack tests " George Guo
2026-11-26  5:53 ` [PATCH bpf-next v1 4/5] selftests/bpf: Enable arena LDSX " George Guo
2026-11-26  5:53 ` [PATCH bpf-next v1 5/5] selftests/bpf: Enable arena atomics " George Guo
2026-11-26  6:06 ` [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena " Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox