Skip to content

Commit d365993

Browse files
author
Alexei Starovoitov
committed
Merge branch 'selftests-bpf-fix-a-few-test-failures-with-arm64-64kb-page'
Yonghong Song says: ==================== selftests/bpf: Fix a few test failures with arm64 64KB page My local arm64 host has 64KB page size and the VM to run test_progs also has 64KB page size. There are a few self tests assuming 4KB page and failed in my environment. Patch 1 reduced long assert logs so if the test fails, developers can check logs easily. Patches 2-4 fixed three selftest failures. Changelogs: v3 -> v4: - v3: https://lore.kernel.org/bpf/[email protected]/ - In v3, I tried to use __kconfig with CONFIG_ARM64_64K_PAGES to decide to have 4K or 64K aligned. But CI seems unhappy about this. Most likely the reason is due to lskel. So in v4, simply adjust/increase numbers to 64K aligned for test_ringbuf_write test. v2 -> v3: - v2: https://lore.kernel.org/bpf/[email protected]/ - Fix veristat failure with bpf object file test_ringbuf_write.bpf.o. v1 -> v2: - v1: https://lore.kernel.org/bpf/[email protected]/ - Fix a problem with selftest release build, basically from BUILD_BUG_ON to ASSERT_LT. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
2 parents 64a064c + bbc7bd6 commit d365993

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int test_setup_uffd(void *fault_addr)
7878
}
7979

8080
uffd_register.range.start = (unsigned long)fault_addr;
81-
uffd_register.range.len = 4096;
81+
uffd_register.range.len = getpagesize();
8282
uffd_register.mode = UFFDIO_REGISTER_MODE_MISSING;
8383
if (ioctl(uffd, UFFDIO_REGISTER, &uffd_register)) {
8484
close(uffd);

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/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;

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,20 @@ static void test_xdp_adjust_frags_tail_grow(void)
246246
ASSERT_EQ(topts.retval, XDP_TX, "9Kb+10b retval");
247247
ASSERT_EQ(topts.data_size_out, exp_size, "9Kb+10b size");
248248

249-
for (i = 0; i < 9000; i++)
250-
ASSERT_EQ(buf[i], 1, "9Kb+10b-old");
249+
for (i = 0; i < 9000; i++) {
250+
if (buf[i] != 1)
251+
ASSERT_EQ(buf[i], 1, "9Kb+10b-old");
252+
}
251253

252-
for (i = 9000; i < 9010; i++)
253-
ASSERT_EQ(buf[i], 0, "9Kb+10b-new");
254+
for (i = 9000; i < 9010; i++) {
255+
if (buf[i] != 0)
256+
ASSERT_EQ(buf[i], 0, "9Kb+10b-new");
257+
}
254258

255-
for (i = 9010; i < 16384; i++)
256-
ASSERT_EQ(buf[i], 1, "9Kb+10b-untouched");
259+
for (i = 9010; i < 16384; i++) {
260+
if (buf[i] != 1)
261+
ASSERT_EQ(buf[i], 1, "9Kb+10b-untouched");
262+
}
257263

258264
/* Test a too large grow */
259265
memset(buf, 1, 16384);

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)