From: Yonghong Song <yonghong.song@linux.dev>
To: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
kernel-team@fb.com, Martin KaFai Lau <martin.lau@kernel.org>
Subject: Re: [PATCH bpf-next 4/4] selftests/bpf: Fix a user_ringbuf failure with arm64 64KB page size
Date: Thu, 5 Jun 2025 22:52:17 -0700 [thread overview]
Message-ID: <22e00248-0b0a-457e-8516-d19d38ac15f9@linux.dev> (raw)
In-Reply-To: <20250606032330.446016-1-yonghong.song@linux.dev>
On 6/5/25 8:23 PM, Yonghong Song wrote:
> 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 | 6 ++++--
> 1 file changed, 4 insertions(+), 2 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..f50aa8e7f6c2 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)
> {
> @@ -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.
next prev parent reply other threads:[~2025-06-06 5:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-06 3:23 [PATCH bpf-next 0/4] selftests/bpf: Fix a few test failures with arm64 64KB page Yonghong Song
2025-06-06 3:23 ` [PATCH bpf-next 1/4] selftests/bpf: Reduce test_xdp_adjust_frags_tail_grow logs Yonghong Song
2025-06-06 3:23 ` [PATCH bpf-next 2/4] selftests/bpf: Fix bpf_mod_race test failure with arm64 64KB page size Yonghong Song
2025-06-06 3:23 ` [PATCH bpf-next 3/4] selftests/bpf: Fix ringbuf/ringbuf_write " Yonghong Song
2025-06-06 3:23 ` [PATCH bpf-next 4/4] selftests/bpf: Fix a user_ringbuf " Yonghong Song
2025-06-06 5:52 ` Yonghong Song [this message]
2025-06-06 6:00 ` Yonghong Song
2025-06-06 16:30 ` [PATCH bpf-next 0/4] selftests/bpf: Fix a few test failures with arm64 64KB page Andrii Nakryiko
2025-06-06 16:37 ` Ihor Solodrai
2025-06-06 16:43 ` Yonghong Song
2025-06-06 16:49 ` Ihor Solodrai
2025-06-06 16:57 ` Andrii Nakryiko
2025-06-06 17:15 ` Ihor Solodrai
2025-06-06 18:21 ` Andrii Nakryiko
2025-06-06 17:03 ` Yonghong Song
2025-06-06 17:19 ` Ihor Solodrai
2025-06-06 18:11 ` Yonghong Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=22e00248-0b0a-457e-8516-d19d38ac15f9@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.