* [PATCH bpf-next v4 0/4] selftests/bpf: Fix a few test failures with arm64 64KB page
@ 2025-06-07 1:36 Yonghong Song
2025-06-07 1:36 ` [PATCH bpf-next v4 1/4] selftests/bpf: Reduce test_xdp_adjust_frags_tail_grow logs Yonghong Song
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Yonghong Song @ 2025-06-07 1:36 UTC (permalink / raw)
To: bpf
Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team,
Martin KaFai Lau
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/20250606213048.340421-1-yonghong.song@linux.dev/
- 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/20250606174139.3036576-1-yonghong.song@linux.dev/
- Fix veristat failure with bpf object file test_ringbuf_write.bpf.o.
v1 -> v2:
- v1: https://lore.kernel.org/bpf/20250606032309.444401-1-yonghong.song@linux.dev/
- Fix a problem with selftest release build, basically from
BUILD_BUG_ON to ASSERT_LT.
Yonghong Song (4):
selftests/bpf: Reduce test_xdp_adjust_frags_tail_grow logs
selftests/bpf: Fix bpf_mod_race test failure with arm64 64KB page size
selftests/bpf: Fix ringbuf/ringbuf_write test failure with arm64 64KB
page size
selftests/bpf: Fix a user_ringbuf failure with arm64 64KB page size
.../selftests/bpf/prog_tests/bpf_mod_race.c | 2 +-
.../testing/selftests/bpf/prog_tests/ringbuf.c | 4 ++--
.../selftests/bpf/prog_tests/user_ringbuf.c | 10 +++++++---
.../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18 ++++++++++++------
.../selftests/bpf/progs/test_ringbuf_write.c | 4 ++--
5 files changed, 24 insertions(+), 14 deletions(-)
--
2.47.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH bpf-next v4 1/4] selftests/bpf: Reduce test_xdp_adjust_frags_tail_grow logs
2025-06-07 1:36 [PATCH bpf-next v4 0/4] selftests/bpf: Fix a few test failures with arm64 64KB page Yonghong Song
@ 2025-06-07 1:36 ` Yonghong Song
2025-06-07 1:36 ` [PATCH bpf-next v4 2/4] selftests/bpf: Fix bpf_mod_race test failure with arm64 64KB page size Yonghong Song
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Yonghong Song @ 2025-06-07 1:36 UTC (permalink / raw)
To: bpf
Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team,
Martin KaFai Lau
For selftest xdp_adjust_tail/xdp_adjust_frags_tail_grow, if tested failure,
I see a long list of log output like
...
test_xdp_adjust_frags_tail_grow:PASS:9Kb+10b-untouched 0 nsec
test_xdp_adjust_frags_tail_grow:PASS:9Kb+10b-untouched 0 nsec
test_xdp_adjust_frags_tail_grow:PASS:9Kb+10b-untouched 0 nsec
test_xdp_adjust_frags_tail_grow:PASS:9Kb+10b-untouched 0 nsec
...
There are total 7374 lines of the above which is too much. Let us
only issue such logs when it is an assert failure.
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
---
.../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c b/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c
index b2b2d85dbb1b..e361129402a1 100644
--- a/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c
+++ b/tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c
@@ -246,14 +246,20 @@ static void test_xdp_adjust_frags_tail_grow(void)
ASSERT_EQ(topts.retval, XDP_TX, "9Kb+10b retval");
ASSERT_EQ(topts.data_size_out, exp_size, "9Kb+10b size");
- for (i = 0; i < 9000; i++)
- ASSERT_EQ(buf[i], 1, "9Kb+10b-old");
+ for (i = 0; i < 9000; i++) {
+ if (buf[i] != 1)
+ ASSERT_EQ(buf[i], 1, "9Kb+10b-old");
+ }
- for (i = 9000; i < 9010; i++)
- ASSERT_EQ(buf[i], 0, "9Kb+10b-new");
+ for (i = 9000; i < 9010; i++) {
+ if (buf[i] != 0)
+ ASSERT_EQ(buf[i], 0, "9Kb+10b-new");
+ }
- for (i = 9010; i < 16384; i++)
- ASSERT_EQ(buf[i], 1, "9Kb+10b-untouched");
+ for (i = 9010; i < 16384; i++) {
+ if (buf[i] != 1)
+ ASSERT_EQ(buf[i], 1, "9Kb+10b-untouched");
+ }
/* Test a too large grow */
memset(buf, 1, 16384);
--
2.47.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH bpf-next v4 2/4] selftests/bpf: Fix bpf_mod_race test failure with arm64 64KB page size
2025-06-07 1:36 [PATCH bpf-next v4 0/4] selftests/bpf: Fix a few test failures with arm64 64KB page Yonghong Song
2025-06-07 1:36 ` [PATCH bpf-next v4 1/4] selftests/bpf: Reduce test_xdp_adjust_frags_tail_grow logs Yonghong Song
@ 2025-06-07 1:36 ` Yonghong Song
2025-06-07 1:36 ` [PATCH bpf-next v4 3/4] selftests/bpf: Fix ringbuf/ringbuf_write " Yonghong Song
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Yonghong Song @ 2025-06-07 1:36 UTC (permalink / raw)
To: bpf
Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team,
Martin KaFai Lau
Currently, uffd_register.range.len is set to 4096 for command
'ioctl(uffd, UFFDIO_REGISTER, &uffd_register)'. For arm64 64KB page size,
the len must be 64KB size aligned as page size alignment is required.
See fs/userfaultfd.c:validate_unaligned_range().
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
---
tools/testing/selftests/bpf/prog_tests/bpf_mod_race.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_mod_race.c b/tools/testing/selftests/bpf/prog_tests/bpf_mod_race.c
index fe2c502e5089..ecc3d47919ad 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_mod_race.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_mod_race.c
@@ -78,7 +78,7 @@ static int test_setup_uffd(void *fault_addr)
}
uffd_register.range.start = (unsigned long)fault_addr;
- uffd_register.range.len = 4096;
+ uffd_register.range.len = getpagesize();
uffd_register.mode = UFFDIO_REGISTER_MODE_MISSING;
if (ioctl(uffd, UFFDIO_REGISTER, &uffd_register)) {
close(uffd);
--
2.47.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH bpf-next v4 3/4] selftests/bpf: Fix ringbuf/ringbuf_write test failure with arm64 64KB page size
2025-06-07 1:36 [PATCH bpf-next v4 0/4] selftests/bpf: Fix a few test failures with arm64 64KB page Yonghong Song
2025-06-07 1:36 ` [PATCH bpf-next v4 1/4] selftests/bpf: Reduce test_xdp_adjust_frags_tail_grow logs Yonghong Song
2025-06-07 1:36 ` [PATCH bpf-next v4 2/4] selftests/bpf: Fix bpf_mod_race test failure with arm64 64KB page size Yonghong Song
@ 2025-06-07 1:36 ` Yonghong Song
2025-06-07 1:36 ` [PATCH bpf-next v4 4/4] selftests/bpf: Fix a user_ringbuf " Yonghong Song
2025-06-07 2:30 ` [PATCH bpf-next v4 0/4] selftests/bpf: Fix a few test failures with arm64 64KB page patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: Yonghong Song @ 2025-06-07 1:36 UTC (permalink / raw)
To: bpf
Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team,
Martin KaFai Lau
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>
---
tools/testing/selftests/bpf/prog_tests/ringbuf.c | 4 ++--
tools/testing/selftests/bpf/progs/test_ringbuf_write.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/ringbuf.c b/tools/testing/selftests/bpf/prog_tests/ringbuf.c
index da430df45aa4..d1e4cb28a72c 100644
--- a/tools/testing/selftests/bpf/prog_tests/ringbuf.c
+++ b/tools/testing/selftests/bpf/prog_tests/ringbuf.c
@@ -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();
diff --git a/tools/testing/selftests/bpf/progs/test_ringbuf_write.c b/tools/testing/selftests/bpf/progs/test_ringbuf_write.c
index 350513c0e4c9..f063a0013f85 100644
--- a/tools/testing/selftests/bpf/progs/test_ringbuf_write.c
+++ b/tools/testing/selftests/bpf/progs/test_ringbuf_write.c
@@ -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);
--
2.47.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH bpf-next v4 4/4] selftests/bpf: Fix a user_ringbuf failure with arm64 64KB page size
2025-06-07 1:36 [PATCH bpf-next v4 0/4] selftests/bpf: Fix a few test failures with arm64 64KB page Yonghong Song
` (2 preceding siblings ...)
2025-06-07 1:36 ` [PATCH bpf-next v4 3/4] selftests/bpf: Fix ringbuf/ringbuf_write " Yonghong Song
@ 2025-06-07 1:36 ` Yonghong Song
2025-06-07 2:30 ` [PATCH bpf-next v4 0/4] selftests/bpf: Fix a few test failures with arm64 64KB page patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: Yonghong Song @ 2025-06-07 1:36 UTC (permalink / raw)
To: bpf
Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team,
Martin KaFai Lau
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 <yonghong.song@linux.dev>
---
tools/testing/selftests/bpf/prog_tests/user_ringbuf.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c b/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c
index d424e7ecbd12..9fd3ae987321 100644
--- a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c
+++ b/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c
@@ -21,8 +21,7 @@
#include "../progs/test_user_ringbuf.h"
static const long c_sample_size = sizeof(struct sample) + BPF_RINGBUF_HDR_SZ;
-static const long c_ringbuf_size = 1 << 12; /* 1 small page */
-static const long c_max_entries = c_ringbuf_size / c_sample_size;
+static long c_ringbuf_size, c_max_entries;
static void drain_current_samples(void)
{
@@ -424,7 +423,9 @@ static void test_user_ringbuf_loop(void)
uint32_t remaining_samples = total_samples;
int err;
- BUILD_BUG_ON(total_samples <= c_max_entries);
+ if (!ASSERT_LT(c_max_entries, total_samples, "compare_c_max_entries"))
+ return;
+
err = load_skel_create_user_ringbuf(&skel, &ringbuf);
if (err)
return;
@@ -686,6 +687,9 @@ void test_user_ringbuf(void)
{
int i;
+ c_ringbuf_size = getpagesize(); /* 1 page */
+ c_max_entries = c_ringbuf_size / c_sample_size;
+
for (i = 0; i < ARRAY_SIZE(success_tests); i++) {
if (!test__start_subtest(success_tests[i].test_name))
continue;
--
2.47.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH bpf-next v4 0/4] selftests/bpf: Fix a few test failures with arm64 64KB page
2025-06-07 1:36 [PATCH bpf-next v4 0/4] selftests/bpf: Fix a few test failures with arm64 64KB page Yonghong Song
` (3 preceding siblings ...)
2025-06-07 1:36 ` [PATCH bpf-next v4 4/4] selftests/bpf: Fix a user_ringbuf " Yonghong Song
@ 2025-06-07 2:30 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-07 2:30 UTC (permalink / raw)
To: Yonghong Song; +Cc: bpf, ast, andrii, daniel, kernel-team, martin.lau
Hello:
This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Fri, 6 Jun 2025 18:36:05 -0700 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [bpf-next,v4,1/4] selftests/bpf: Reduce test_xdp_adjust_frags_tail_grow logs
https://git.kernel.org/bpf/bpf-next/c/ae8824037a0a
- [bpf-next,v4,2/4] selftests/bpf: Fix bpf_mod_race test failure with arm64 64KB page size
https://git.kernel.org/bpf/bpf-next/c/377d3715900c
- [bpf-next,v4,3/4] selftests/bpf: Fix ringbuf/ringbuf_write test failure with arm64 64KB page size
https://git.kernel.org/bpf/bpf-next/c/8c8c5e3c854a
- [bpf-next,v4,4/4] selftests/bpf: Fix a user_ringbuf failure with arm64 64KB page size
https://git.kernel.org/bpf/bpf-next/c/bbc7bd658ddc
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-06-07 2:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-07 1:36 [PATCH bpf-next v4 0/4] selftests/bpf: Fix a few test failures with arm64 64KB page Yonghong Song
2025-06-07 1:36 ` [PATCH bpf-next v4 1/4] selftests/bpf: Reduce test_xdp_adjust_frags_tail_grow logs Yonghong Song
2025-06-07 1:36 ` [PATCH bpf-next v4 2/4] selftests/bpf: Fix bpf_mod_race test failure with arm64 64KB page size Yonghong Song
2025-06-07 1:36 ` [PATCH bpf-next v4 3/4] selftests/bpf: Fix ringbuf/ringbuf_write " Yonghong Song
2025-06-07 1:36 ` [PATCH bpf-next v4 4/4] selftests/bpf: Fix a user_ringbuf " Yonghong Song
2025-06-07 2:30 ` [PATCH bpf-next v4 0/4] selftests/bpf: Fix a few test failures with arm64 64KB page patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.