From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: "Ihor Solodrai" <ihor.solodrai@linux.dev>,
"Alexei Starovoitov" <ast@kernel.org>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Amery Hung" <ameryhung@gmail.com>
Cc: "Mykyta Yatsenko" <yatsenko@meta.com>, <bpf@vger.kernel.org>,
<kernel-team@meta.com>
Subject: Re: [PATCH bpf-next v2] selftests/bpf: Fix flakiness of task_local_storage/sys_enter_exit
Date: Tue, 24 Feb 2026 16:14:35 -0500 [thread overview]
Message-ID: <DGNI488GTNDF.10SWXYT5VSWVV@etsalapatis.com> (raw)
In-Reply-To: <20260224211202.214325-1-ihor.solodrai@linux.dev>
On Tue Feb 24, 2026 at 4:12 PM EST, Ihor Solodrai wrote:
> The test_sys_enter_exit test was setting target_pid before attaching
> the BPF programs, which causes syscalls made during the attach phase
> to be counted. This is flaky because, apparently, there is no
> guarantee that both on_enter and on_exit will trigger during the
> attachment.
>
> Move the target_pid assignment to after task_local_storage__attach()
> so that only explicit sys_gettid() calls are counted.
>
> Reported-by: BPF CI Bot (Claude Opus 4.6) <bot+bpf-ci@kernel.org>
> Closes: https://github.com/kernel-patches/vmtest/issues/448
> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
>
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
> ---
>
> v1->v2: reset skel->bss->target_pid to 0 before asserts (Amery)
> v1: https://lore.kernel.org/bpf/20260224015855.1481707-1-ihor.solodrai@linux.dev/
>
> ---
> .../bpf/prog_tests/task_local_storage.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 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 7bee33797c71..1b26c12f255a 100644
> --- a/tools/testing/selftests/bpf/prog_tests/task_local_storage.c
> +++ b/tools/testing/selftests/bpf/prog_tests/task_local_storage.c
> @@ -25,24 +25,30 @@
> static void test_sys_enter_exit(void)
> {
> struct task_local_storage *skel;
> + pid_t pid = sys_gettid();
> int err;
>
> skel = task_local_storage__open_and_load();
> if (!ASSERT_OK_PTR(skel, "skel_open_and_load"))
> return;
>
> - skel->bss->target_pid = sys_gettid();
> -
> err = task_local_storage__attach(skel);
> if (!ASSERT_OK(err, "skel_attach"))
> goto out;
>
> + /* Set target_pid after attach so that syscalls made during
> + * attach are not counted.
> + */
> + skel->bss->target_pid = pid;
> +
> sys_gettid();
> sys_gettid();
>
> - /* 3x syscalls: 1x attach and 2x gettid */
> - ASSERT_EQ(skel->bss->enter_cnt, 3, "enter_cnt");
> - ASSERT_EQ(skel->bss->exit_cnt, 3, "exit_cnt");
> + skel->bss->target_pid = 0;
> +
> + /* 2x gettid syscalls */
> + ASSERT_EQ(skel->bss->enter_cnt, 2, "enter_cnt");
> + ASSERT_EQ(skel->bss->exit_cnt, 2, "exit_cnt");
> ASSERT_EQ(skel->bss->mismatch_cnt, 0, "mismatch_cnt");
> out:
> task_local_storage__destroy(skel);
next prev parent reply other threads:[~2026-02-24 21:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 21:12 [PATCH bpf-next v2] selftests/bpf: Fix flakiness of task_local_storage/sys_enter_exit Ihor Solodrai
2026-02-24 21:14 ` Emil Tsalapatis [this message]
2026-02-24 22:04 ` Amery Hung
2026-02-24 22:49 ` Ihor Solodrai
2026-02-24 23:00 ` patchwork-bot+netdevbpf
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=DGNI488GTNDF.10SWXYT5VSWVV@etsalapatis.com \
--to=emil@etsalapatis.com \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@meta.com \
--cc=yatsenko@meta.com \
/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.