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

selftests/bpf: Fix a user_ringbuf failure with arm64 64KB page size

The ringbuf max_entries must be PAGE_ALIGNED. See kernel function
ringbuf_map_alloc(). So for arm64 64KB page size, adjust max_entries
properly.

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20250607013626.1553001-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Yonghong Song and committed by
Alexei Starovoitov
bbc7bd65 8c8c5e3c

+7 -3
+7 -3
tools/testing/selftests/bpf/prog_tests/user_ringbuf.c
··· 21 21 #include "../progs/test_user_ringbuf.h" 22 22 23 23 static const long c_sample_size = sizeof(struct sample) + BPF_RINGBUF_HDR_SZ; 24 - static const long c_ringbuf_size = 1 << 12; /* 1 small page */ 25 - static const long c_max_entries = c_ringbuf_size / c_sample_size; 24 + static long c_ringbuf_size, c_max_entries; 26 25 27 26 static void drain_current_samples(void) 28 27 { ··· 423 424 uint32_t remaining_samples = total_samples; 424 425 int err; 425 426 426 - BUILD_BUG_ON(total_samples <= c_max_entries); 427 + if (!ASSERT_LT(c_max_entries, total_samples, "compare_c_max_entries")) 428 + return; 429 + 427 430 err = load_skel_create_user_ringbuf(&skel, &ringbuf); 428 431 if (err) 429 432 return; ··· 686 685 void test_user_ringbuf(void) 687 686 { 688 687 int i; 688 + 689 + c_ringbuf_size = getpagesize(); /* 1 page */ 690 + c_max_entries = c_ringbuf_size / c_sample_size; 689 691 690 692 for (i = 0; i < ARRAY_SIZE(success_tests); i++) { 691 693 if (!test__start_subtest(success_tests[i].test_name))