]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests/bpf: Fix ringbuf/ringbuf_write test failure with arm64 64KB page size
authorYonghong Song <yonghong.song@linux.dev>
Sat, 7 Jun 2025 01:36:21 +0000 (18:36 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 7 Jun 2025 02:21:43 +0000 (19:21 -0700)
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 <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20250607013621.1552332-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/ringbuf.c
tools/testing/selftests/bpf/progs/test_ringbuf_write.c

index da430df45aa497f7e18e57913057f5bec97797a8..d1e4cb28a72c6bbb87b3cc1b216d5634fffb6736 100644 (file)
@@ -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();
index 350513c0e4c985341b6e9921727309d20dbb5923..f063a0013f8506aae4a143d87d4779684ae09055 100644 (file)
@@ -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);