From: Gabriel Krisman Bertazi <krisman@suse.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: io-uring <io-uring@vger.kernel.org>,
Max Kellermann <max.kellermann@ionos.com>
Subject: Re: [PATCH v2] io_uring/io-wq: fix incorrect io_wq_for_each_worker() termination logic
Date: Mon, 05 Jan 2026 13:07:27 -0500 [thread overview]
Message-ID: <87y0mc6ihs.fsf@mailhost.krisman.be> (raw)
In-Reply-To: <f98f318f-0c3b-4b01-afb2-2b276f3fe6cd@kernel.dk> (Jens Axboe's message of "Mon, 5 Jan 2026 09:57:43 -0700")
Jens Axboe <axboe@kernel.dk> writes:
> A previous commit added this helper, and had it terminate if false is
> returned from the handler. However, that is completely opposite, it
> should abort the loop if true is returned.
>
> Fix this up by having io_wq_for_each_worker() keep iterating as long
> as false is returned, and only abort if true is returned.
The fix is good, but the API is just weird.
io_acct_for_each_worker returning true indicates an error that will
abort the wq walk. It is a non-issue, since all the two callers cannot
fail and always return false for success :-)
Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>
> Cc: stable@vger.kernel.org
> Fixes: 751eedc4b4b7 ("io_uring/io-wq: move worker lists to struct io_wq_acct")
> Signed-off-by: Jens Axboe <axboe@kernel.dk>
>
> ---
>
> v2: fix the actual bug, rather than work-around it for the exit
> condition only.
>
> diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c
> index cd13d8aac3d2..6c5ef629e59a 100644
> --- a/io_uring/io-wq.c
> +++ b/io_uring/io-wq.c
> @@ -952,11 +952,11 @@ static bool io_wq_for_each_worker(struct io_wq *wq,
> void *data)
> {
> for (int i = 0; i < IO_WQ_ACCT_NR; i++) {
> - if (!io_acct_for_each_worker(&wq->acct[i], func, data))
> - return false;
> + if (io_acct_for_each_worker(&wq->acct[i], func, data))
> + return true;
> }
>
> - return true;
> + return false;
> }
>
> static bool io_wq_worker_wake(struct io_worker *worker, void *data)
--
Gabriel Krisman Bertazi
next prev parent reply other threads:[~2026-01-05 18:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 16:57 [PATCH v2] io_uring/io-wq: fix incorrect io_wq_for_each_worker() termination logic Jens Axboe
2026-01-05 18:07 ` Gabriel Krisman Bertazi [this message]
2026-01-05 18:41 ` Jens Axboe
2026-01-05 18:54 ` David Kahurani
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=87y0mc6ihs.fsf@mailhost.krisman.be \
--to=krisman@suse.de \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=max.kellermann@ionos.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox