Skip to content

Commit 8c8c5e3

Browse files
Yonghong SongAlexei Starovoitov
authored andcommitted
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: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 377d371 commit 8c8c5e3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tools/testing/selftests/bpf/prog_tests/ringbuf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static void ringbuf_write_subtest(void)
9797
if (!ASSERT_OK_PTR(skel, "skel_open"))
9898
return;
9999

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

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

114114
skel->bss->pid = getpid();

tools/testing/selftests/bpf/progs/test_ringbuf_write.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ int test_ringbuf_write(void *ctx)
2626
if (cur_pid != pid)
2727
return 0;
2828

29-
sample1 = bpf_ringbuf_reserve(&ringbuf, 0x3000, 0);
29+
sample1 = bpf_ringbuf_reserve(&ringbuf, 0x30000, 0);
3030
if (!sample1)
3131
return 0;
3232
/* first one can pass */
33-
sample2 = bpf_ringbuf_reserve(&ringbuf, 0x3000, 0);
33+
sample2 = bpf_ringbuf_reserve(&ringbuf, 0x30000, 0);
3434
if (!sample2) {
3535
bpf_ringbuf_discard(sample1, 0);
3636
__sync_fetch_and_add(&discarded, 1);

0 commit comments

Comments
 (0)