From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: <thamrinjonathan@gmail.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"Shuah Khan" <shuah@kernel.org>
Cc: <bpf@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf-next] selftests/bpf: Fix wq test by changing 50us sleep to polling over 1s
Date: Mon, 19 Oct 2026 03:31:30 +0200 [thread overview]
Message-ID: <DM8FDI32CJ1Y.2JOM7KJERMF7M@gmail.com> (raw)
In-Reply-To: <20261005-wq-poll-fix-v1-1-99ce4bac59f4@gmail.com>
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
prev parent reply other threads:[~2026-10-19 1:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 9:37 Jonathan Bastari Thamrin via B4 Relay
2026-10-19 1:31 ` Kumar Kartikeya Dwivedi [this message]
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=DM8FDI32CJ1Y.2JOM7KJERMF7M@gmail.com \
--to=memxor@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=thamrinjonathan@gmail.com \
--cc=yonghong.song@linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®