Skip to content

Commit bbc7bd6

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

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
#include "../progs/test_user_ringbuf.h"
2222

2323
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;
2625

2726
static void drain_current_samples(void)
2827
{
@@ -424,7 +423,9 @@ static void test_user_ringbuf_loop(void)
424423
uint32_t remaining_samples = total_samples;
425424
int err;
426425

427-
BUILD_BUG_ON(total_samples <= c_max_entries);
426+
if (!ASSERT_LT(c_max_entries, total_samples, "compare_c_max_entries"))
427+
return;
428+
428429
err = load_skel_create_user_ringbuf(&skel, &ringbuf);
429430
if (err)
430431
return;
@@ -686,6 +687,9 @@ void test_user_ringbuf(void)
686687
{
687688
int i;
688689

690+
c_ringbuf_size = getpagesize(); /* 1 page */
691+
c_max_entries = c_ringbuf_size / c_sample_size;
692+
689693
for (i = 0; i < ARRAY_SIZE(success_tests); i++) {
690694
if (!test__start_subtest(success_tests[i].test_name))
691695
continue;

0 commit comments

Comments
 (0)