The Linux Kernel Mailing 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

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