* [PATCH bpf-next] selftests/bpf: Fix wq test by changing 50us sleep to polling over 1s
@ 2026-10-05 9:37 Jonathan Bastari Thamrin via B4 Relay
2026-10-19 1:31 ` Kumar Kartikeya Dwivedi
0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Bastari Thamrin via B4 Relay @ 2026-10-05 9:37 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi, Martin KaFai Lau,
Song Liu, Yonghong Song, Jiri Olsa, Emil Tsalapatis,
Ihor Solodrai, Shuah Khan
Cc: bpf, linux-kselftest, linux-kernel, Jonathan Bastari Thamrin
From: Jonathan Bastari Thamrin <thamrinjonathan@gmail.com>
wq test fails with ok_sleepable reading 0 instead of 2 as workqueue
callback hasn't executed before check.
This happens as callback runs later on a kworker and 50us isn't always
enough.
Change from 50us sleep to polling over 1s.
Before (usleep(50)): 3 fails out of 5000 runs
Diagnosing issue (usleep(0)): 23 out of 100 runs
After (Polling): 0 out of 5000 runs
Tested using vmtest on x86_64, test pinned to one CPU with `yes` load
Link: https://github.com/kernel-patches/vmtest/issues/455
Signed-off-by: Jonathan Bastari Thamrin <thamrinjonathan@gmail.com>
---
tools/testing/selftests/bpf/prog_tests/wq.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/wq.c b/tools/testing/selftests/bpf/prog_tests/wq.c
index 84831eecc..b55d8547f 100644
--- a/tools/testing/selftests/bpf/prog_tests/wq.c
+++ b/tools/testing/selftests/bpf/prog_tests/wq.c
@@ -7,7 +7,7 @@
void serial_test_wq(void)
{
struct wq *wq_skel = NULL;
- int err, prog_fd;
+ int err, prog_fd, tries;
LIBBPF_OPTS(bpf_test_run_opts, topts);
@@ -28,7 +28,13 @@ void serial_test_wq(void)
ASSERT_OK(err, "test_run");
ASSERT_EQ(topts.retval, 0, "test_run");
- usleep(50); /* 10 usecs should be enough, but give it extra */
+ /* loop check over 1 sec to make sure it doesn't fail early when busy */
+ for (tries = 1000; tries >= 0; tries--) {
+ if (wq_skel->bss->ok_sleepable == (1 << 1))
+ break;
+
+ usleep(1000);
+ }
ASSERT_EQ(wq_skel->bss->ok_sleepable, (1 << 1), "ok_sleepable");
clean_up:
---
base-commit: b5a4aa31abd6fe90009b63e35dc18c67d041ec0c
change-id: 20261005-wq-poll-fix-f46c47dbaf03
Best regards,
--
Jonathan Bastari Thamrin <thamrinjonathan@gmail.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Fix wq test by changing 50us sleep to polling over 1s
2026-10-05 9:37 [PATCH bpf-next] selftests/bpf: Fix wq test by changing 50us sleep to polling over 1s Jonathan Bastari Thamrin via B4 Relay
@ 2026-10-19 1:31 ` Kumar Kartikeya Dwivedi
0 siblings, 0 replies; 2+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2026-10-19 1:31 UTC (permalink / raw)
To: thamrinjonathan, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Eduard Zingerman, Martin KaFai Lau, Song Liu,
Yonghong Song, Jiri Olsa, Emil Tsalapatis, Ihor Solodrai,
Shuah Khan
Cc: bpf, linux-kselftest, linux-kernel
On Mon Oct 5, 2026 at 11:37 AM CEST, Jonathan Bastari Thamrin via B4 Relay wrote:
> From: Jonathan Bastari Thamrin <thamrinjonathan@gmail.com>
>
> wq test fails with ok_sleepable reading 0 instead of 2 as workqueue
> callback hasn't executed before check.
>
> This happens as callback runs later on a kworker and 50us isn't always
> enough.
>
> Change from 50us sleep to polling over 1s.
>
> Before (usleep(50)): 3 fails out of 5000 runs
> Diagnosing issue (usleep(0)): 23 out of 100 runs
> After (Polling): 0 out of 5000 runs
> Tested using vmtest on x86_64, test pinned to one CPU with `yes` load
>
> Link: https://github.com/kernel-patches/vmtest/issues/455
>
> Signed-off-by: Jonathan Bastari Thamrin <thamrinjonathan@gmail.com>
> ---
> tools/testing/selftests/bpf/prog_tests/wq.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/wq.c b/tools/testing/selftests/bpf/prog_tests/wq.c
> index 84831eecc..b55d8547f 100644
> --- a/tools/testing/selftests/bpf/prog_tests/wq.c
> +++ b/tools/testing/selftests/bpf/prog_tests/wq.c
> @@ -7,7 +7,7 @@
> void serial_test_wq(void)
> {
> struct wq *wq_skel = NULL;
> - int err, prog_fd;
> + int err, prog_fd, tries;
>
> LIBBPF_OPTS(bpf_test_run_opts, topts);
>
> @@ -28,7 +28,13 @@ void serial_test_wq(void)
> ASSERT_OK(err, "test_run");
> ASSERT_EQ(topts.retval, 0, "test_run");
>
> - usleep(50); /* 10 usecs should be enough, but give it extra */
> + /* loop check over 1 sec to make sure it doesn't fail early when busy */
> + for (tries = 1000; tries >= 0; tries--) {
> + if (wq_skel->bss->ok_sleepable == (1 << 1))
> + break;
> +
> + usleep(1000);
> + }
>
Please figure out the actual condition this loop is trying to wait for and
establish it directly, there are several examples in the selftests.
pw-bot: cr
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-19 1:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-05 9:37 [PATCH bpf-next] selftests/bpf: Fix wq test by changing 50us sleep to polling over 1s Jonathan Bastari Thamrin via B4 Relay
2026-10-19 1:31 ` Kumar Kartikeya Dwivedi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox