BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v2] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free
@ 2026-12-01  3:44 George Guo
  2026-12-01  4:06 ` Alexei Starovoitov
  2026-12-01  4:11 ` bot+bpf-ci
  0 siblings, 2 replies; 3+ messages in thread
From: George Guo @ 2026-12-01  3:44 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: emil, bpf, linux-kselftest, 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, and building the BPF selftests with clang 19 fails:

  test_buddy.bpf.c:109: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>
---
v1 was patch 1/5 of "selftests/bpf: Enable private stack, large stack
and arena tests for LoongArch":
https://lore.kernel.org/bpf/20261126055355.9967-2-dongtai.guo@linux.dev/

Changes in v2:
- Send it on its own. The fix does not depend on LoongArch, while the
  rest of that series waits for the LoongArch JIT changes.
- Fix the line number in the quoted error (109, not 80).
- Reword the commit message.

 .../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)

base-commit: 0dbb0bea76960c41194677d39da65cdfd9f813ad
-- 
2.53.0


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

* Re: [PATCH bpf-next v2] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free
  2026-12-01  3:44 [PATCH bpf-next v2] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free George Guo
@ 2026-12-01  4:06 ` Alexei Starovoitov
  2026-12-01  4:11 ` bot+bpf-ci
  1 sibling, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2026-12-01  4:06 UTC (permalink / raw)
  To: George Guo, daniel, andrii, eddyz87, memxor
  Cc: emil, bpf, linux-kselftest, linux-kernel, George Guo

On Mon, Nov 30, 2026 at 07:44 PM George Guo <dongtai.guo@linux.dev> wrote:
> 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, and building the BPF selftests with clang 19 fails:
>
>   test_buddy.bpf.c:109:54: error: unsupported signed division, please convert to unsigned div/mod.

In June you reported that clang 19 cannot build libarena at all:
https://lore.kernel.org/bpf/20260630025809.74043-1-dongtai.guo@linux.dev/

  fatal error: error in backend: Cannot select: AtomicCmpSwap<(s32)> ...
  In function: arena_spin_lock_slowpath

arena_spin_lock_slowpath() still has the 32-bit cmpxchg.
libarena/Makefile still passes no -mcpu.
By that report the build with clang 19 fails with and without this patch.

The answer is the same as in June. Pls upgrade clang.

pw-bot: cr

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

* Re: [PATCH bpf-next v2] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free
  2026-12-01  3:44 [PATCH bpf-next v2] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free George Guo
  2026-12-01  4:06 ` Alexei Starovoitov
@ 2026-12-01  4:11 ` bot+bpf-ci
  1 sibling, 0 replies; 3+ messages in thread
From: bot+bpf-ci @ 2026-12-01  4:11 UTC (permalink / raw)
  To: dongtai.guo, ast, daniel, andrii, eddyz87, memxor
  Cc: emil, bpf, linux-kselftest, linux-kernel, guodongtai, ast, andrii,
	daniel, martin.lau, eddyz87, yonghong.song, mason, ihor.solodrai

[-- Attachment #1: Type: text/plain, Size: 1531 bytes --]

> selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free

TL;DR: Possible justification problem: the unsigned counter may not make
libarena build with clang 19, since the arena_spin_lock_slowpath() 32-bit
cmpxchg appears to still fail; Alexei's v2 concern looks unaddressed.

> diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_buddy.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_buddy.bpf.c
> --- 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)

Alexei Starovoitov raised a concern about the justification for this change
in v2:

> By that report the build with clang 19 fails with and without this patch.
> The answer is the same as in June. Pls upgrade clang.

Does this change actually make libarena build with clang 19?

arena_spin_lock_slowpath() still has a 32-bit cmpxchg that fails with
"Cannot select: AtomicCmpSwap", and libarena/Makefile passes no -mcpu, so
the build appears to fail with and without this patch.

Has this concern been addressed?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46572595446

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

end of thread, other threads:[~2026-12-01  4:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  3:44 [PATCH bpf-next v2] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free George Guo
2026-12-01  4:06 ` Alexei Starovoitov
2026-12-01  4:11 ` bot+bpf-ci

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