From: Jens Axboe <axboe@kernel.dk>
To: io-uring@vger.kernel.org
Cc: changfengnan@bytedance.com, lidiangang@bytedance.com,
Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 2/3] io_uring/io-wq: ignore non-busy worker going to sleep
Date: Fri, 23 May 2025 06:15:14 -0600 [thread overview]
Message-ID: <20250523121749.1252334-3-axboe@kernel.dk> (raw)
In-Reply-To: <20250523121749.1252334-1-axboe@kernel.dk>
When an io-wq worker goes to sleep, it checks if there's work to do.
If there is, it'll create a new worker. But if this worker is currently
idle, it'll either get woken right back up immediately, or someone
else has already created the necessary worker to handle this work.
Only go through the worker creation logic if the current worker is
currently handling a work item. That means it's being scheduled out as
part of handling that work, not just going to sleep on its own.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
io_uring/io-wq.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c
index d36d0bd9847d..c4af99460399 100644
--- a/io_uring/io-wq.c
+++ b/io_uring/io-wq.c
@@ -429,6 +429,8 @@ static void io_wq_dec_running(struct io_worker *worker)
if (!atomic_dec_and_test(&acct->nr_running))
return;
+ if (!worker->cur_work)
+ return;
if (!io_acct_run_queue(acct))
return;
--
2.49.0
next prev parent reply other threads:[~2025-05-23 12:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 12:15 [PATCHSET 0/3] Avoid unnecessary io-wq worker creation Jens Axboe
2025-05-23 12:15 ` [PATCH 1/3] io_uring/io-wq: move hash helpers to the top Jens Axboe
2025-05-23 12:15 ` Jens Axboe [this message]
2025-05-23 12:15 ` [PATCH 3/3] io_uring/io-wq: only create a new worker if it can make progress Jens Axboe
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=20250523121749.1252334-3-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=changfengnan@bytedance.com \
--cc=io-uring@vger.kernel.org \
--cc=lidiangang@bytedance.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