* [PATCH bpf-next 0/2] selftests/bpf: Fix flaky verifier_arena_large/big_alloc3
@ 2026-11-24 17:08 Mykyta Yatsenko
2026-11-24 17:08 ` [PATCH bpf-next 1/2] selftests/bpf: Let __skip() report SKIP for a return value Mykyta Yatsenko
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mykyta Yatsenko @ 2026-11-24 17:08 UTC (permalink / raw)
To: bpf, ast, andrii, daniel, kernel-team, eddyz87, ihor.solodrai
Cc: Mykyta Yatsenko
big_alloc3 allocates 1025 arena pages in a nonsleepable program. That
allocation does not reclaim, so it can fail when memory is low. BPF CI
sees this as a FAIL on aarch64. When the allocation fails, the test
cannot do its check, so the correct result is SKIP, not OK or FAIL.
Patch 1 lets test_loader report SKIP at run time: __skip() with a
__retval() right after it, like __success __retval(0).
Patch 2 uses it in big_alloc3 and runs verifier_arena_large serially.
Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
---
Mykyta Yatsenko (2):
selftests/bpf: Let __skip() report SKIP for a return value
selftests/bpf: Fix flaky verifier_arena_large/big_alloc3
tools/testing/selftests/bpf/prog_tests/verifier.c | 3 +-
tools/testing/selftests/bpf/progs/bpf_misc.h | 6 ++++
.../selftests/bpf/progs/verifier_arena_large.c | 9 +++++-
tools/testing/selftests/bpf/test_loader.c | 35 ++++++++++++++++++++--
4 files changed, 49 insertions(+), 4 deletions(-)
---
base-commit: 966e9d6e515bdd60f401b16eabc10eadca5f7885
change-id: 20261124-arena_big_alloc3-ddff2d311b40
Best regards,
--
Mykyta Yatsenko <yatsenko@meta.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH bpf-next 1/2] selftests/bpf: Let __skip() report SKIP for a return value
2026-11-24 17:08 [PATCH bpf-next 0/2] selftests/bpf: Fix flaky verifier_arena_large/big_alloc3 Mykyta Yatsenko
@ 2026-11-24 17:08 ` Mykyta Yatsenko
2026-11-24 17:08 ` [PATCH bpf-next 2/2] selftests/bpf: Fix flaky verifier_arena_large/big_alloc3 Mykyta Yatsenko
2026-12-03 5:00 ` [PATCH bpf-next 0/2] " patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Mykyta Yatsenko @ 2026-11-24 17:08 UTC (permalink / raw)
To: bpf, ast, andrii, daniel, kernel-team, eddyz87, ihor.solodrai
Cc: Mykyta Yatsenko
From: Mykyta Yatsenko <yatsenko@meta.com>
Some test programs need a resource that the kernel can refuse at run
time, for example memory for a nonsleepable allocation. If the kernel
refuses it, the program cannot do its check, and the correct result is
SKIP, not OK or FAIL. __skip() can only report SKIP without running the
program.
If __retval() comes right after __skip(), run the program, and report
SKIP with the reason when the program returns that value. The usage is
like __success __retval(0):
__success __retval(0)
__skip("no memory") __retval(1)
No program has __retval() right after __skip() now, so this does not
change existing tests.
Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
---
tools/testing/selftests/bpf/progs/bpf_misc.h | 6 +++++
tools/testing/selftests/bpf/test_loader.c | 35 ++++++++++++++++++++++++++--
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h b/tools/testing/selftests/bpf/progs/bpf_misc.h
index 6b930cb48f8d2..4e6b8a5714407 100644
--- a/tools/testing/selftests/bpf/progs/bpf_misc.h
+++ b/tools/testing/selftests/bpf/progs/bpf_misc.h
@@ -115,6 +115,12 @@
* running it. For placeholder programs that stand in for a
* feature the toolchain or JIT cannot provide, so a run does
* not report OK for coverage it never executed.
+ * With __retval right after __skip, run the program and
+ * report SKIP only if it returns that value. For programs
+ * that need a resource the kernel can refuse at run time:
+ *
+ * __success __retval(0)
+ * __skip("no memory") __retval(1)
*
* __skip_without_arena
* __skip() when the compiler does not support the arena
diff --git a/tools/testing/selftests/bpf/test_loader.c b/tools/testing/selftests/bpf/test_loader.c
index d24e4fedae46f..4baee582d6ec3 100644
--- a/tools/testing/selftests/bpf/test_loader.c
+++ b/tools/testing/selftests/bpf/test_loader.c
@@ -78,6 +78,8 @@ struct test_spec {
int stack_mask;
int linear_sz;
const char *skip_reason;
+ const char *skip_retval_reason;
+ int skip_retval;
bool prepare_priv;
bool auxiliary;
bool valid;
@@ -380,6 +382,19 @@ static const char **collect_decl_tags(struct btf *btf, int id, int *cnt)
return tags;
}
+/* Return the value of the __retval tag right after tags[i], or NULL */
+static const char *next_retval_tag(const char **tags, int i, int nr_tags)
+{
+ const char *s;
+
+ if (i + 1 >= nr_tags)
+ return NULL;
+ s = skip_decl_tag_pfx(tags[i + 1]);
+ if (!s)
+ return NULL;
+ return str_has_pfx(s, "test_retval=");
+}
+
enum arch {
ARCH_UNKNOWN = 0x1,
ARCH_X86_64 = 0x2,
@@ -457,7 +472,7 @@ static int parse_test_spec(struct test_loader *tester,
return PTR_ERR(tags);
for (i = 0; i < nr_tags; i++) {
- const char *s, *val, *msg;
+ const char *s, *val, *msg, *skip_val;
bool clear;
int flags;
@@ -467,7 +482,18 @@ static int parse_test_spec(struct test_loader *tester,
if ((val = str_has_pfx(s, "test_description="))) {
description = val;
} else if ((val = str_has_pfx(s, "test_skip="))) {
- spec->skip_reason = val;
+ /* __skip() __retval(N): SKIP when the run returns N */
+ skip_val = next_retval_tag(tags, i, nr_tags);
+ if (!skip_val) {
+ spec->skip_reason = val;
+ continue;
+ }
+ err = parse_retval(skip_val, &spec->skip_retval, "__retval");
+ if (err)
+ goto cleanup;
+ spec->skip_retval_reason = val;
+ spec->priv.execute = true;
+ i++;
} else if (strcmp(s, "test_expect_failure") == 0) {
spec->priv.expect_failure = true;
spec->mode_mask |= PRIV;
@@ -1547,6 +1573,11 @@ void run_subtest(struct test_loader *tester,
bpf_program__type(tprog) == BPF_PROG_TYPE_SYSCALL ||
bpf_program__type(tprog) == BPF_PROG_TYPE_RAW_TRACEPOINT,
spec->linear_sz);
+ if (!err && spec->skip_retval_reason && retval == spec->skip_retval) {
+ printf("%s:SKIP: %s\n", __func__, spec->skip_retval_reason);
+ test__skip();
+ goto tobj_cleanup;
+ }
if (!err && retval != subspec->retval && subspec->retval != POINTER_VALUE) {
PRINT_FAIL("Unexpected retval: %d != %d\n", retval, subspec->retval);
goto tobj_cleanup;
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH bpf-next 2/2] selftests/bpf: Fix flaky verifier_arena_large/big_alloc3
2026-11-24 17:08 [PATCH bpf-next 0/2] selftests/bpf: Fix flaky verifier_arena_large/big_alloc3 Mykyta Yatsenko
2026-11-24 17:08 ` [PATCH bpf-next 1/2] selftests/bpf: Let __skip() report SKIP for a return value Mykyta Yatsenko
@ 2026-11-24 17:08 ` Mykyta Yatsenko
2026-12-03 5:00 ` [PATCH bpf-next 0/2] " patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Mykyta Yatsenko @ 2026-11-24 17:08 UTC (permalink / raw)
To: bpf, ast, andrii, daniel, kernel-team, eddyz87, ihor.solodrai
Cc: Mykyta Yatsenko
From: Mykyta Yatsenko <yatsenko@meta.com>
big_alloc3 is a nonsleepable program, so bpf_arena_alloc_pages() takes
each of its 1025 pages from alloc_pages_nolock(). That call does not
reclaim and only uses trylock, so it can fail when memory is low. BPF CI
sees this on aarch64 as "Unexpected retval: 1 != 0". In a KASAN VM each
arena also takes 512 MB of shadow memory, and verifier_arena_large runs
in parallel with other arena tests.
Commit 317a5df78f24 ("selftests/bpf: Fix verifier_arena_large/big_alloc3
test") counted a failed allocation as a pass. The commit below made it a
failure again. Both results are wrong, because the check did not run.
Report SKIP instead, with __skip() __retval(1). big_alloc4 still checks
the sleepable path, which can reclaim. Also run verifier_arena_large
serially, as commit a14f9ba080c1 ("selftests/bpf: Run arena tests
serially") does for the arena_* tests.
Fixes: 0f6512272538 ("selftests/bpf: Test large allocations for both sleepable/nonsleepable arena users")
Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
---
tools/testing/selftests/bpf/prog_tests/verifier.c | 3 ++-
tools/testing/selftests/bpf/progs/verifier_arena_large.c | 9 ++++++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/verifier.c b/tools/testing/selftests/bpf/prog_tests/verifier.c
index 816ab3cfafc74..f6bc573886b41 100644
--- a/tools/testing/selftests/bpf/prog_tests/verifier.c
+++ b/tools/testing/selftests/bpf/prog_tests/verifier.c
@@ -233,7 +233,8 @@ void test_verifier_and(void) { RUN(verifier_and); }
void test_verifier_arena(void) { RUN(verifier_arena); }
void test_verifier_arena_cast(void) { RUN(verifier_arena_cast); }
void test_verifier_arena_stack(void) { RUN_TESTS(verifier_arena_stack); }
-void test_verifier_arena_large(void) { RUN(verifier_arena_large); }
+/* Serial, as prog_tests/arena_*.c: each arena takes 512 MB of KASAN shadow */
+void serial_test_verifier_arena_large(void) { RUN(verifier_arena_large); }
void test_verifier_arena_globals1(void) { RUN(verifier_arena_globals1); }
void test_verifier_arena_globals2(void) { RUN(verifier_arena_globals2); }
void test_verifier_barrier(void) { RUN(verifier_barrier); }
diff --git a/tools/testing/selftests/bpf/progs/verifier_arena_large.c b/tools/testing/selftests/bpf/progs/verifier_arena_large.c
index 89f32a7772ac2..e6f7adc90c6be 100644
--- a/tools/testing/selftests/bpf/progs/verifier_arena_large.c
+++ b/tools/testing/selftests/bpf/progs/verifier_arena_large.c
@@ -284,6 +284,7 @@ int big_alloc2(void *ctx)
/* Nonsleepable because it binds to a socket program. */
SEC("socket")
__success __retval(0)
+__skip("nonsleepable allocation failed") __retval(1)
__skip_without_arena
int big_alloc3(void *ctx)
{
@@ -291,7 +292,13 @@ int big_alloc3(void *ctx)
u64 i;
int err = 0;
- /* Verify that a nonsleepable allocation larger than 1024 pages succeeds. */
+ /*
+ * Verify that a nonsleepable allocation larger than 1024 pages works.
+ * Each page comes from alloc_pages_nolock(), which does not reclaim and
+ * only uses trylock, so the allocation can fail when memory is low,
+ * for example in a small KASAN VM. If it fails, return 1 to report
+ * SKIP. big_alloc4 checks the sleepable path, which can reclaim.
+ */
pages = bpf_arena_alloc_pages(&arena, NULL, LARGE_PAGE_CNT, NUMA_NO_NODE, 0);
if (!pages)
return 1;
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next 0/2] selftests/bpf: Fix flaky verifier_arena_large/big_alloc3
2026-11-24 17:08 [PATCH bpf-next 0/2] selftests/bpf: Fix flaky verifier_arena_large/big_alloc3 Mykyta Yatsenko
2026-11-24 17:08 ` [PATCH bpf-next 1/2] selftests/bpf: Let __skip() report SKIP for a return value Mykyta Yatsenko
2026-11-24 17:08 ` [PATCH bpf-next 2/2] selftests/bpf: Fix flaky verifier_arena_large/big_alloc3 Mykyta Yatsenko
@ 2026-12-03 5:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-12-03 5:00 UTC (permalink / raw)
To: Mykyta Yatsenko
Cc: bpf, ast, andrii, daniel, kernel-team, eddyz87, ihor.solodrai,
yatsenko
Hello:
This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Tue, 24 Nov 2026 09:08:07 -0800 you wrote:
> big_alloc3 allocates 1025 arena pages in a nonsleepable program. That
> allocation does not reclaim, so it can fail when memory is low. BPF CI
> sees this as a FAIL on aarch64. When the allocation fails, the test
> cannot do its check, so the correct result is SKIP, not OK or FAIL.
>
> Patch 1 lets test_loader report SKIP at run time: __skip() with a
> __retval() right after it, like __success __retval(0).
> Patch 2 uses it in big_alloc3 and runs verifier_arena_large serially.
>
> [...]
Here is the summary with links:
- [bpf-next,1/2] selftests/bpf: Let __skip() report SKIP for a return value
https://git.kernel.org/bpf/bpf-next/c/afb01da47e16
- [bpf-next,2/2] selftests/bpf: Fix flaky verifier_arena_large/big_alloc3
https://git.kernel.org/bpf/bpf-next/c/9cc066395b82
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] 4+ messages in thread
end of thread, other threads:[~2026-12-03 5:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 17:08 [PATCH bpf-next 0/2] selftests/bpf: Fix flaky verifier_arena_large/big_alloc3 Mykyta Yatsenko
2026-11-24 17:08 ` [PATCH bpf-next 1/2] selftests/bpf: Let __skip() report SKIP for a return value Mykyta Yatsenko
2026-11-24 17:08 ` [PATCH bpf-next 2/2] selftests/bpf: Fix flaky verifier_arena_large/big_alloc3 Mykyta Yatsenko
2026-12-03 5:00 ` [PATCH bpf-next 0/2] " patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox