BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: Drop the on_enter recursion check of task_local_storage
@ 2026-10-09  1:49 Qiliang Yuan
  2026-10-09  1:57 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Qiliang Yuan @ 2026-10-09  1:49 UTC (permalink / raw)
  To: Andrii Nakryiko, Eduard Zingerman, Ihor Solodrai,
	Alexei Starovoitov, Daniel Borkmann, Kumar Kartikeya Dwivedi,
	Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa,
	Emil Tsalapatis, Shuah Khan
  Cc: bpf, linux-kselftest, linux-kernel, Qiliang Yuan

test_recursion attaches on_enter to sys_enter and on_update to
bpf_local_storage_update, makes one syscall, and checks the task
storage values left behind and the recursion misses of both programs.

on_enter runs for every syscall of the system and returns early for
other tasks. On a preemptible kernel, a task can be preempted while it
runs on_enter, and a task entering a syscall on the same CPU then misses
the program. With other tests running in parallel, on_enter ends up
with recursion misses that have nothing to do with the test task, and
the check expecting none fails.

Drop the check. map_a holding 200, which only on_enter of the test task
writes, already shows that on_enter ran for it.

Fixes: 387b532138ee ("selftests/bpf: Tracing prog can still do lookup under busy lock")
Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
---
 tools/testing/selftests/bpf/prog_tests/task_local_storage.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/task_local_storage.c b/tools/testing/selftests/bpf/prog_tests/task_local_storage.c
index 5b2b56cc3a4f3..c03ea94325d9e 100644
--- a/tools/testing/selftests/bpf/prog_tests/task_local_storage.c
+++ b/tools/testing/selftests/bpf/prog_tests/task_local_storage.c
@@ -138,12 +138,6 @@ static void test_recursion(void)
 	ASSERT_OK(err, "get prog info");
 	ASSERT_EQ(info.recursion_misses, 2, "on_update prog recursion");
 
-	prog_fd = bpf_program__fd(skel->progs.on_enter);
-	memset(&info, 0, sizeof(info));
-	err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
-	ASSERT_OK(err, "get prog info");
-	ASSERT_EQ(info.recursion_misses, 0, "on_enter prog recursion");
-
 out:
 	close(task_fd);
 	task_ls_recursion__destroy(skel);

---
base-commit: e1d84a37cba984388988d2f1ddc84561413f0db2
change-id: 20261009-selftests-bpf-task-ls-recursion-5a85b5d499ef

Best regards,
-- 
Qiliang Yuan <odys.yuan@gmail.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: Drop the on_enter recursion check of task_local_storage
  2026-10-09  1:49 [PATCH bpf-next] selftests/bpf: Drop the on_enter recursion check of task_local_storage Qiliang Yuan
@ 2026-10-09  1:57 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-09  1:57 UTC (permalink / raw)
  To: Qiliang Yuan; +Cc: bpf

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] bpf: incomplete fix for flaky task_local_storage recursion test
--

commit 93ecb8817313103c1cdb556cb288695d3d3c939c
Author: Qiliang Yuan <odys.yuan@gmail.com>

selftests/bpf: Drop the on_enter recursion check of task_local_storage

This commit removes the recursion misses check for the on_enter program
in the task_local_storage test to fix test flakiness. It prevents failures
caused by preemption-induced spurious misses when other tasks trigger
sys_enter on the same CPU.

> diff --git a/tools/testing/selftests/bpf/prog_tests/task_local_storage.c b/tools/testing/selftests/bpf/prog_tests/task_local_storage.c
> index 5b2b56cc3a4f3..c03ea94325d9e 100644
> --- a/tools/testing/selftests/bpf/prog_tests/task_local_storage.c
> +++ b/tools/testing/selftests/bpf/prog_tests/task_local_storage.c
> @@ -138,12 +138,6 @@ static void test_recursion(void)
>  	ASSERT_OK(err, "get prog info");
>  	ASSERT_EQ(info.recursion_misses, 2, "on_update prog recursion");

[Severity: Low]
Is this exact-match assertion susceptible to the same preemption-induced
spurious misses that this patch aims to fix for on_enter?

The on_update program is an fentry program attached to the globally shared
bpf_local_storage_update function, which also executes in a preemptible
context (rcu_read_lock_dont_migrate()).

If a task is preempted while executing on_update, its prog->active recursion
counter remains elevated on that CPU.

If the preempting task (such as another selftest thread running in parallel)
calls bpf_local_storage_update, the fentry trampoline will check the elevated
recursion context, increment the program's global recursion_misses counter,
and abort before the test_pid filter inside the program is evaluated.

This spurious miss could randomly push info.recursion_misses above 2, leaving
the test flaky.

Would it be safer to relax this check to
ASSERT_GE(info.recursion_misses, 2, "on_update prog recursion")?

> -	prog_fd = bpf_program__fd(skel->progs.on_enter);
> -	memset(&info, 0, sizeof(info));
> -	err = bpf_prog_get_info_by_fd(prog_fd, &info, &info_len);
> -	ASSERT_OK(err, "get prog info");
> -	ASSERT_EQ(info.recursion_misses, 0, "on_enter prog recursion");
> -
>  out:
>  	close(task_fd);
>  	task_ls_recursion__destroy(skel);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261009-selftests-bpf-task-ls-recursion-v1-1-c3a3e3c41f8c@gmail.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-09  1:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-09  1:49 [PATCH bpf-next] selftests/bpf: Drop the on_enter recursion check of task_local_storage Qiliang Yuan
2026-10-09  1:57 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox