Skip to contentSkip to conversation

selftests/bpf: Fix a few test failures with arm64 64KB page

PATCH Superseded Yonghong Song 3 participants 17 messages Jun 6, 2025

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Yonghong Song

author reviewer
#0 lore raw

cover 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 hence failed in my envorinment. Patch 1 tries to reduce long assert logs when tail failed. Patches 2-4 fixed three selftest failures.

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 |  5 +++--
 .../selftests/bpf/prog_tests/user_ringbuf.c    |  6 ++++--
 .../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18 ++++++++++++------
 .../selftests/bpf/progs/test_ringbuf_write.c   |  5 +++--
 5 files changed, 23 insertions(+), 13 deletions(-)
Signature · 1 line
2.47.1
author reviewer
#1 lore raw

PATCH 1/4 selftests/bpf: Reduce test_xdp_adjust_frags_tail_grow logs

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.

---
 .../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
tools/testing/selftests/bpf/prog_tests/xdp_adjust_tail.c +12 -6
index b2b2d85dbb1b..e361129402a1 100644
@@ -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);
Signature · 1 line
2.47.1
author reviewer
#2 lore raw

PATCH 2/4 selftests/bpf: Fix bpf_mod_race test failure with arm64 64KB page size

In reply to Yonghong Song

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().

---
 tools/testing/selftests/bpf/prog_tests/bpf_mod_race.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/bpf_mod_race.c +1 -1
index fe2c502e5089..ecc3d47919ad 100644
@@ -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);
Signature · 1 line
2.47.1
author reviewer
#3 lore raw

PATCH 3/4 selftests/bpf: Fix ringbuf/ringbuf_write test failure with arm64 64KB page size

In reply to Yonghong Song

The ringbuf max_entries must be PAGE_ALIGNED. See kernel function ringbuf_map_alloc(). So for arm64 64KB page size, adjust max_entries properly.

---
 tools/testing/selftests/bpf/prog_tests/ringbuf.c       | 5 +++--
 tools/testing/selftests/bpf/progs/test_ringbuf_write.c | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/prog_tests/ringbuf.c +3 -2
index da430df45aa4..89fd3401a23e 100644
@@ -97,7 +97,8 @@ 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 = 4 * page_size;
+	skel->rodata->reserve_size = 3 * page_size;
 
 	err = test_ringbuf_write_lskel__load(skel);
 	if (!ASSERT_OK(err, "skel_load"))
@@ -108,7 +109,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 = 3 * page_size;
 	ASSERT_OK(munmap(mmap_ptr, page_size), "unmap_rw");
 
 	skel->bss->pid = getpid();
tools/testing/selftests/bpf/progs/test_ringbuf_write.c +3 -2
index 350513c0e4c9..9acef7afbe8a 100644
@@ -12,6 +12,7 @@ struct {
 
 /* inputs */
 int pid = 0;
+const volatile int reserve_size = 0;
 
 /* outputs */
 long passed = 0;
@@ -26,11 +27,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, reserve_size, 0);
 	if (!sample1)
 		return 0;
 	/* first one can pass */
-	sample2 = bpf_ringbuf_reserve(&ringbuf, 0x3000, 0);
+	sample2 = bpf_ringbuf_reserve(&ringbuf, reserve_size, 0);
 	if (!sample2) {
 		bpf_ringbuf_discard(sample1, 0);
 		__sync_fetch_and_add(&discarded, 1);
Signature · 1 line
2.47.1
author reviewer
#4 lore raw

PATCH 4/4 selftests/bpf: Fix a user_ringbuf failure with arm64 64KB page size

In reply to Yonghong Song

The ringbuf max_entries must be PAGE_ALIGNED. See kernel function ringbuf_map_alloc(). So for arm64 64KB page size, adjust max_entries properly.

---
 tools/testing/selftests/bpf/prog_tests/user_ringbuf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/user_ringbuf.c +4 -2
index d424e7ecbd12..f50aa8e7f6c2 100644
@@ -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)
 {
@@ -686,6 +685,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;
Signature · 1 line
2.47.1
author reviewer
#5 lore raw

Re: [PATCH bpf-next 4/4] selftests/bpf: Fix a user_ringbuf failure with arm64 64KB page size

Quoted 24 lines · Yonghong Song

The ringbuf max_entries must be PAGE_ALIGNED. See kernel function ringbuf_map_alloc(). So for arm64 64KB page size, adjust max_entries properly.

---
  tools/testing/selftests/bpf/prog_tests/user_ringbuf.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/user_ringbuf.c +1 -2
index d424e7ecbd12..f50aa8e7f6c2 100644
@@ -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)
  {

tools/testing/selftests/bpf/prog_tests/user_ringbuf.c void test_user_ringbuf(void) · line 693

Quoted 9 lines
tools/testing/selftests/bpf/prog_tests/user_ringbuf.c +3 -0
@@ -686,6 +685,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;

CI reports a build failure error:

/tmp/work/bpf/bpf/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c:426:2: error: call to '__compiletime_assert_0' declared with 'error' attribute: BUILD_BUG_ON failed: total_samples <= c_max_entries 426 | BUILD_BUG_ON(total_samples <= c_max_entries |

/tmp/work/bpf/bpf/tools/include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON' 50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) | ^ /tmp/work/bpf/bpf/tools/include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG' 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) | ^ /tmp/work/bpf/bpf/tools/include/linux/compiler.h:37:2: note: expanded from macro 'compiletime_assert' 37 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^ /tmp/work/bpf/bpf/tools/include/linux/compiler.h:25:2: note: expanded from macro '_compiletime_assert' 25 | __compiletime_assert(condition, msg, prefix, suffix) | ^ /tmp/work/bpf/bpf/tools/include/linux/compiler.h:18:4: note: expanded from macro '__compiletime_assert' 18 | prefix ## suffix(); \ | ^ <scratch space>:60:1: note: expanded from here 60 | __compiletime_assert_0

| ^ This happens for the release build (RELEASE=1 in build command line where -O2 is used in stead of -O0). Converting the BUILD_BUG_ON to ASSERT can fix the problem. diff --git a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c b/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c index f50aa8e7f6c2..467b5b8beecc 100644 --- a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c +++ b/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c @@ -423,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_LE(total_samples, c_max_entries, "compare_c_max_entries")) + return; + err = load_skel_create_user_ringbuf(&skel, &ringbuf); I will wait for some further comments before posting v2.

author reviewer
#6 lore raw

Re: [PATCH bpf-next 4/4] selftests/bpf: Fix a user_ringbuf failure with arm64 64KB page size

Quoted 36 lines · Yonghong Song
Quoted 24 lines · Yonghong Song

The ringbuf max_entries must be PAGE_ALIGNED. See kernel function ringbuf_map_alloc(). So for arm64 64KB page size, adjust max_entries properly.

---
  tools/testing/selftests/bpf/prog_tests/user_ringbuf.c | 6 ++++--

  1 file changed, 4 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/user_ringbuf.c +1 -2
index d424e7ecbd12..f50aa8e7f6c2 100644
@@ -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)
   {
@@ -686,6 +685,9 @@ void test_user_ringbuf(void)
   {
       int i;
Quoted 6 lines

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

CI reports a build failure error:

Quoted 7 lines

/tmp/work/bpf/bpf/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c:426:2: error: call to '__compiletime_assert_0' declared with 'error' attribute: BUILD_BUG_ON failed: total_samples <= c_max_entries   426 | BUILD_BUG_ON(total_samples <= c_max_entries     |

/tmp/work/bpf/bpf/tools/include/linux/build_bug.h:50:2: note: expanded from macro 'BUILD_BUG_ON' 50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) | ^ /tmp/work/bpf/bpf/tools/include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG' 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) | ^ /tmp/work/bpf/bpf/tools/include/linux/compiler.h:37:2: note: expanded from macro 'compiletime_assert' 37 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^ /tmp/work/bpf/bpf/tools/include/linux/compiler.h:25:2: note: expanded from macro '_compiletime_assert' 25 | __compiletime_assert(condition, msg, prefix, suffix) | ^ /tmp/work/bpf/bpf/tools/include/linux/compiler.h:18:4: note: expanded from macro '__compiletime_assert' 18 | prefix ## suffix(); \ | ^ <scratch space>:60:1: note: expanded from here 60 | __compiletime_assert_0

| ^ This happens for the release build (RELEASE=1 in build command line where -O2 is used in stead of -O0). Converting the BUILD_BUG_ON to ASSERT can fix the problem. diff --git a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c b/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c index f50aa8e7f6c2..467b5b8beecc 100644 --- a/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c +++ b/tools/testing/selftests/bpf/prog_tests/user_ringbuf.c @@ -423,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_LE(total_samples, c_max_entries, "compare_c_max_entries")) + return; + err = load_skel_create_user_ringbuf(&skel, &ringbuf); I will wait for some further comments before posting v2.

Sorry for mess up. Basically, need to replace a BUILD_BUG_ON with a ASSERT... I already tried to format the code properly but somehow still messed up. Will debug/double-check this next time.

#7 lore raw
In reply to Yonghong Song
Quoted 4 lines · Yonghong Song

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 hence failed in my envorinment. Patch 1 tries to reduce long assert

typo: environment

Quoted 1 line

logs when tail failed. Patches 2-4 fixed three selftest failures.

How come our BPF CI doesn't catch this on aarch64?.. Ihor, any thoughts?

Quoted 18 lines

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 |  5 +++--
 .../selftests/bpf/prog_tests/user_ringbuf.c    |  6 ++++--
 .../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18 ++++++++++++------
 .../selftests/bpf/progs/test_ringbuf_write.c   |  5 +++--
 5 files changed, 23 insertions(+), 13 deletions(-)

--
2.47.1

reviewer
#8 lore raw
Quoted 11 lines · Andrii Nakryiko
Quoted 4 lines · Yonghong Song

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 hence failed in my envorinment. Patch 1 tries to reduce long assert

typo: environment

Quoted 1 line

logs when tail failed. Patches 2-4 fixed three selftest failures.

How come our BPF CI doesn't catch this on aarch64?.. Ihor, any thoughts?

Because our aarch64 hosts use 4K pagesize...

$ uname -a
Linux ip-10-0-0-103.us-west-1.compute.internal 5.10.228-219.884.amzn2.aarch64 #1 SMP Wed Oct 23 17:17:31 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
[ec2-user@ip-10-0-0-103 ~]$ getconf PAGESIZE
4096
Quoted 19 lines
Quoted 19 lines

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 |  5 +++--
  .../selftests/bpf/prog_tests/user_ringbuf.c    |  6 ++++--
  .../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18 ++++++++++++------
  .../selftests/bpf/progs/test_ringbuf_write.c   |  5 +++--
  5 files changed, 23 insertions(+), 13 deletions(-)

--
2.47.1

author reviewer
#9 lore raw
In reply to Andrii Nakryiko
Quoted 8 lines · Andrii Nakryiko
Quoted 3 lines · Yonghong Song

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 hence failed in my envorinment. Patch 1 tries to reduce long assert

typo: environment

Quoted 1 line

logs when tail failed. Patches 2-4 fixed three selftest failures.

How come our BPF CI doesn't catch this on aarch64?.. Ihor, any thoughts?

In CI for aarch64, the page size is 4KB. For example, for this link:

https://github.com/kernel-patches/bpf/actions/runs/15482212552/job/43590176563?pr=9053

Find the kconfig, and we have

CONFIG_ARM64_4K_PAGES=y
# CONFIG_ARM64_16K_PAGES is not set
# CONFIG_ARM64_64K_PAGES is not set

and for 4K page, all these tests are fine, but not for 64K page.

Quoted 18 lines
Quoted 18 lines

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 |  5 +++--
  .../selftests/bpf/prog_tests/user_ringbuf.c    |  6 ++++--
  .../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18 ++++++++++++------
  .../selftests/bpf/progs/test_ringbuf_write.c   |  5 +++--
  5 files changed, 23 insertions(+), 13 deletions(-)

--
2.47.1

reviewer
#10 lore raw
Quoted 16 lines · Yonghong Song
Quoted 8 lines · Andrii Nakryiko
Quoted 3 lines · Yonghong Song

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 hence failed in my envorinment. Patch 1 tries to reduce long assert

typo: environment

Quoted 1 line

logs when tail failed. Patches 2-4 fixed three selftest failures.

How come our BPF CI doesn't catch this on aarch64?.. Ihor, any thoughts?

In CI for aarch64, the page size is 4KB. For example, for this link:

https://github.com/kernel-patches/bpf/actions/runs/15482212552/ job/43590176563?pr=9053

Quoted 7 lines

Find the kconfig, and we have

  CONFIG_ARM64_4K_PAGES=y
  # CONFIG_ARM64_16K_PAGES is not set
  # CONFIG_ARM64_64K_PAGES is not set

and for 4K page, all these tests are fine, but not for 64K page.

Ah right, I just realized the host pagesize doesn't matter, the kernel we are running tests against needs to be re-compiled with the right config.

If this is important to test on CI, it can be another matrix dimension with customized kconfig. Do we want to do that?

Quoted 21 lines
Quoted 20 lines
Quoted 20 lines

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 |  5 +++-- .../selftests/bpf/prog_tests/user_ringbuf.c    |  6 ++++-- .../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18 ++++++++++++------ .../selftests/bpf/progs/test_ringbuf_write.c   |  5 +++--

  5 files changed, 23 insertions(+), 13 deletions(-)
Signature · 1 line
2.47.1
#11 lore raw
Quoted 26 lines · Ihor Solodrai
Quoted 24 lines · Yonghong Song
Quoted 9 lines · Andrii Nakryiko
Quoted 3 lines · Yonghong Song

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 hence failed in my envorinment. Patch 1 tries to reduce long assert

typo: environment

Quoted 1 line

logs when tail failed. Patches 2-4 fixed three selftest failures.

How come our BPF CI doesn't catch this on aarch64?.. Ihor, any thoughts?

In CI for aarch64, the page size is 4KB. For example, for this link:

https://github.com/kernel-patches/bpf/actions/runs/15482212552/
job/43590176563?pr=9053

Find the kconfig, and we have

CONFIG_ARM64_4K_PAGES=y
# CONFIG_ARM64_16K_PAGES is not set
# CONFIG_ARM64_64K_PAGES is not set

Quoted 9 lines
Quoted 1 line

and for 4K page, all these tests are fine, but not for 64K page.

Ah right, I just realized the host pagesize doesn't matter, the kernel we are running tests against needs to be re-compiled with the right config.

If this is important to test on CI, it can be another matrix dimension with customized kconfig. Do we want to do that?

Can we just use 64KB page size for aarch64 (no 4KB variant for arm64)?

Quoted 24 lines
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines

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 |  5 +++--
  .../selftests/bpf/prog_tests/user_ringbuf.c    |  6 ++++--
  .../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18 ++++++++++++------
  .../selftests/bpf/progs/test_ringbuf_write.c   |  5 +++--
  5 files changed, 23 insertions(+), 13 deletions(-)

--
2.47.1

reviewer
#12 lore raw
Quoted 33 lines · Andrii Nakryiko
Quoted 32 lines · Ihor Solodrai
Quoted 18 lines · Yonghong Song
Quoted 9 lines · Andrii Nakryiko
Quoted 3 lines · Yonghong Song

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 hence failed in my envorinment. Patch 1 tries to reduce long assert

typo: environment

Quoted 1 line

logs when tail failed. Patches 2-4 fixed three selftest failures.

How come our BPF CI doesn't catch this on aarch64?.. Ihor, any thoughts?

In CI for aarch64, the page size is 4KB. For example, for this link:

https://github.com/kernel-patches/bpf/actions/runs/15482212552/
job/43590176563?pr=9053

Quoted 7 lines

Find the kconfig, and we have

CONFIG_ARM64_4K_PAGES=y
# CONFIG_ARM64_16K_PAGES is not set
# CONFIG_ARM64_64K_PAGES is not set

and for 4K page, all these tests are fine, but not for 64K page.

Ah right, I just realized the host pagesize doesn't matter, the kernel we are running tests against needs to be re-compiled with the right config.

Quoted 5 lines
Quoted 3 lines

If this is important to test on CI, it can be another matrix dimension with customized kconfig. Do we want to do that?

Can we just use 64KB page size for aarch64 (no 4KB variant for arm64)?

We certainly can, but *not* testing 4k pages on any arch seems like a bad idea to me.

If we think a step further, there are many permutations of important configs that we do not test. And it's impractical to test *everything* for each pending patch.

What we could do is split BPF CI into two domains:
* test most important configurations on every patch like we do now
* test other config permutations on base branches (bpf-next, bpf) *sometimes*

We have reserved hardware that is often idle when there is low activity on the list, and it could be used to run other things:
older/newer compilers, different page sizes, particular kconfigs etc.

This way we would catch problems earlier without overloading/expanding the CI infra.

It's an effort to setup of course, but that's how I would approach it if we're serious about testing uncommon things.

Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines

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 |  5 +++--
   .../selftests/bpf/prog_tests/user_ringbuf.c    |  6 ++++--
   .../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18 ++++++++++++------
   .../selftests/bpf/progs/test_ringbuf_write.c   |  5 +++--
   5 files changed, 23 insertions(+), 13 deletions(-)

--
2.47.1

#13 lore raw
Quoted 35 lines · Ihor Solodrai
Quoted 33 lines · Andrii Nakryiko
Quoted 32 lines · Ihor Solodrai
Quoted 18 lines · Yonghong Song
Quoted 9 lines · Andrii Nakryiko
Quoted 3 lines · Yonghong Song

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 hence failed in my envorinment. Patch 1 tries to reduce long assert

typo: environment

Quoted 1 line

logs when tail failed. Patches 2-4 fixed three selftest failures.

How come our BPF CI doesn't catch this on aarch64?.. Ihor, any thoughts?

In CI for aarch64, the page size is 4KB. For example, for this link:

https://github.com/kernel-patches/bpf/actions/runs/15482212552/
job/43590176563?pr=9053

Quoted 7 lines

Find the kconfig, and we have

CONFIG_ARM64_4K_PAGES=y
# CONFIG_ARM64_16K_PAGES is not set
# CONFIG_ARM64_64K_PAGES is not set

and for 4K page, all these tests are fine, but not for 64K page.

Ah right, I just realized the host pagesize doesn't matter, the kernel we are running tests against needs to be re-compiled with the right config.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

If this is important to test on CI, it can be another matrix dimension with customized kconfig. Do we want to do that?

Can we just use 64KB page size for aarch64 (no 4KB variant for arm64)?

We certainly can, but *not* testing 4k pages on any arch seems like a bad idea to me.

No-no, x86 should stay 4KB (can it even be 64KB page size on x86?). But if it's hard to do 64KB on AWS arm64, so be it.

Quoted 46 lines

If we think a step further, there are many permutations of important configs that we do not test. And it's impractical to test *everything* for each pending patch.

What we could do is split BPF CI into two domains:
* test most important configurations on every patch like we do now
* test other config permutations on base branches (bpf-next, bpf) *sometimes*

We have reserved hardware that is often idle when there is low activity on the list, and it could be used to run other things:
older/newer compilers, different page sizes, particular kconfigs etc.

This way we would catch problems earlier without overloading/expanding the CI infra.

It's an effort to setup of course, but that's how I would approach it if we're serious about testing uncommon things.

Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines

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 |  5 +++--
   .../selftests/bpf/prog_tests/user_ringbuf.c    |  6 ++++--
   .../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18 ++++++++++++------
   .../selftests/bpf/progs/test_ringbuf_write.c   |  5 +++--
   5 files changed, 23 insertions(+), 13 deletions(-)

--
2.47.1

author reviewer
#14 lore raw
In reply to Ihor Solodrai
Quoted 23 lines · Ihor Solodrai
Quoted 22 lines · Yonghong Song
Quoted 8 lines · Andrii Nakryiko
Quoted 3 lines · Yonghong Song

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 hence failed in my envorinment. Patch 1 tries to reduce long assert

typo: environment

Quoted 1 line

logs when tail failed. Patches 2-4 fixed three selftest failures.

How come our BPF CI doesn't catch this on aarch64?.. Ihor, any thoughts?

In CI for aarch64, the page size is 4KB. For example, for this link:

https://github.com/kernel-patches/bpf/actions/runs/15482212552/ job/43590176563?pr=9053

Find the kconfig, and we have

   CONFIG_ARM64_4K_PAGES=y
   # CONFIG_ARM64_16K_PAGES is not set
   # CONFIG_ARM64_64K_PAGES is not set

Quoted 5 lines
Quoted 1 line

and for 4K page, all these tests are fine, but not for 64K page.

Ah right, I just realized the host pagesize doesn't matter, the kernel we are running tests against needs to be re-compiled with the right config.

Actually, the host pagesize matters too.

For example, for trace_printk.lskel.h which is used to build bpf binary at an aarch64 host and that aarch64 host is 64KB page.
In trace_printk.lskel.h, we have
...
skel->bss = skel_finalize_map_data(&skel->maps.bss.initial_value,

       65536, PROT_READ | PROT_WRITE, skel->maps.bss.map_fd);

...

Note that the number '65536' is used here to do mmap.

For an x86 host, the number will be 4096 (4KB) instead of 64KB.

For this bpf prog on aarch64, if the VM has page size 4KB, something could go wrong.

So the best is to have the same page size for host and VM for selftests.

Quoted 28 lines

If this is important to test on CI, it can be another matrix dimension with customized kconfig. Do we want to do that?

Quoted 22 lines
Quoted 21 lines
Quoted 21 lines

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 |  5 +++-- .../selftests/bpf/prog_tests/user_ringbuf.c    |  6 ++++-- .../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18
++++++++++++------
  .../selftests/bpf/progs/test_ringbuf_write.c   |  5 +++--

  5 files changed, 23 insertions(+), 13 deletions(-)
Signature · 1 line
2.47.1
reviewer
#15 lore raw
Quoted 42 lines · Yonghong Song
Quoted 23 lines · Ihor Solodrai
Quoted 22 lines · Yonghong Song
Quoted 8 lines · Andrii Nakryiko
Quoted 3 lines · Yonghong Song

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 hence failed in my envorinment. Patch 1 tries to reduce long assert

typo: environment

Quoted 1 line

logs when tail failed. Patches 2-4 fixed three selftest failures.

How come our BPF CI doesn't catch this on aarch64?.. Ihor, any thoughts?

In CI for aarch64, the page size is 4KB. For example, for this link:

https://github.com/kernel-patches/bpf/actions/runs/15482212552/ job/43590176563?pr=9053

Find the kconfig, and we have

   CONFIG_ARM64_4K_PAGES=y
   # CONFIG_ARM64_16K_PAGES is not set
   # CONFIG_ARM64_64K_PAGES is not set

Quoted 5 lines
Quoted 1 line

and for 4K page, all these tests are fine, but not for 64K page.

Ah right, I just realized the host pagesize doesn't matter, the kernel we are running tests against needs to be re-compiled with the right config.

Actually, the host pagesize matters too.

For example, for trace_printk.lskel.h which is used to build bpf binary at an aarch64 host and that aarch64 host is 64KB page.
In trace_printk.lskel.h, we have
   ...
   skel->bss = skel_finalize_map_data(&skel->maps.bss.initial_value, 65536, PROT_READ | PROT_WRITE, skel->maps.bss.map_fd);
   ...

Quoted 8 lines

Note that the number '65536' is used here to do mmap.

For an x86 host, the number will be 4096 (4KB) instead of 64KB.

For this bpf prog on aarch64, if the VM has page size 4KB, something could go wrong.

So the best is to have the same page size for host and VM for selftests.

If the host/vm page size difference only impacts certain tests, we could denylist them. But if it makes the kernel or selftests more unstable in general, then we'll have to switch the hosts.

I don't know how difficult it is to get a 64k page machine on AWS, could be a challenge.

Quoted 31 lines
Quoted 30 lines

If this is important to test on CI, it can be another matrix dimension with customized kconfig. Do we want to do that?

Quoted 22 lines
Quoted 21 lines
Quoted 21 lines

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 |  5 +++-- .../selftests/bpf/prog_tests/user_ringbuf.c    |  6 ++++-- .../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18 +++++++++++

+------
  .../selftests/bpf/progs/test_ringbuf_write.c   |  5 +++--
  5 files changed, 23 insertions(+), 13 deletions(-)
Signature · 1 line
2.47.1
author reviewer
#16 lore raw
Quoted 45 lines · Ihor Solodrai
Quoted 44 lines · Yonghong Song
Quoted 23 lines · Ihor Solodrai
Quoted 22 lines · Yonghong Song
Quoted 8 lines · Andrii Nakryiko
Quoted 3 lines · Yonghong Song

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 hence failed in my envorinment. Patch 1 tries to reduce long assert

typo: environment

Quoted 1 line

logs when tail failed. Patches 2-4 fixed three selftest failures.

How come our BPF CI doesn't catch this on aarch64?.. Ihor, any thoughts?

In CI for aarch64, the page size is 4KB. For example, for this link:

https://github.com/kernel-patches/bpf/actions/runs/15482212552/ job/43590176563?pr=9053

Find the kconfig, and we have

   CONFIG_ARM64_4K_PAGES=y
   # CONFIG_ARM64_16K_PAGES is not set
   # CONFIG_ARM64_64K_PAGES is not set

Quoted 5 lines
Quoted 1 line

and for 4K page, all these tests are fine, but not for 64K page.

Ah right, I just realized the host pagesize doesn't matter, the kernel we are running tests against needs to be re-compiled with the right config.

Actually, the host pagesize matters too.

For example, for trace_printk.lskel.h which is used to build bpf binary at an aarch64 host and that aarch64 host is 64KB page.
In trace_printk.lskel.h, we have
    ...
    skel->bss = skel_finalize_map_data(&skel->maps.bss.initial_value, 65536, PROT_READ | PROT_WRITE, skel->maps.bss.map_fd);
    ...

Note that the number '65536' is used here to do mmap.

Quoted 8 lines
Quoted 6 lines

For an x86 host, the number will be 4096 (4KB) instead of 64KB.

For this bpf prog on aarch64, if the VM has page size 4KB, something could go wrong.

So the best is to have the same page size for host and VM for selftests.

If the host/vm page size difference only impacts certain tests, we

For an arm64 host with 64KB page size,
I tested with VM with 4KB and 64KB page size. Using 4KB page in VM will have 10 more test failures compared to 64KB page in VM.

Quoted 5 lines

could denylist them. But if it makes the kernel or selftests more unstable in general, then we'll have to switch the hosts.

I don't know how difficult it is to get a 64k page machine on AWS, could be a challenge.

I agreed with Andrii. It would be great if we can replace a machine with 64KB so we won't increase capacity and have one more page size to test. Not sure how difficult it is.

Quoted 33 lines
Quoted 32 lines
Quoted 31 lines

If this is important to test on CI, it can be another matrix dimension with customized kconfig. Do we want to do that?

Quoted 22 lines
Quoted 21 lines
Quoted 21 lines

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 |  5 +++-- .../selftests/bpf/prog_tests/user_ringbuf.c    |  6 ++++-- .../selftests/bpf/prog_tests/xdp_adjust_tail.c | 18 +++++++++++

+------
  .../selftests/bpf/progs/test_ringbuf_write.c   |  5 +++--
  5 files changed, 23 insertions(+), 13 deletions(-)
Signature · 1 line
2.47.1