Commit 8c8c5e3c authored by Yonghong Song's avatar Yonghong Song Committed by Alexei Starovoitov
Browse files

selftests/bpf: Fix ringbuf/ringbuf_write test 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
and other related metrics properly.

Signed-off-by: default avatarYonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20250607013621.1552332-1-yonghong.song@linux.dev


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 377d3715
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ static void ringbuf_write_subtest(void)
	if (!ASSERT_OK_PTR(skel, "skel_open"))
		return;

	skel->maps.ringbuf.max_entries = 0x4000;
	skel->maps.ringbuf.max_entries = 0x40000;

	err = test_ringbuf_write_lskel__load(skel);
	if (!ASSERT_OK(err, "skel_load"))
@@ -108,7 +108,7 @@ static void ringbuf_write_subtest(void)
	mmap_ptr = mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, rb_fd, 0);
	if (!ASSERT_OK_PTR(mmap_ptr, "rw_cons_pos"))
		goto cleanup;
	*mmap_ptr = 0x3000;
	*mmap_ptr = 0x30000;
	ASSERT_OK(munmap(mmap_ptr, page_size), "unmap_rw");

	skel->bss->pid = getpid();
+2 −2
Original line number Diff line number Diff line
@@ -26,11 +26,11 @@ int test_ringbuf_write(void *ctx)
	if (cur_pid != pid)
		return 0;

	sample1 = bpf_ringbuf_reserve(&ringbuf, 0x3000, 0);
	sample1 = bpf_ringbuf_reserve(&ringbuf, 0x30000, 0);
	if (!sample1)
		return 0;
	/* first one can pass */
	sample2 = bpf_ringbuf_reserve(&ringbuf, 0x3000, 0);
	sample2 = bpf_ringbuf_reserve(&ringbuf, 0x30000, 0);
	if (!sample2) {
		bpf_ringbuf_discard(sample1, 0);
		__sync_fetch_and_add(&discarded, 1);