From: Jens Axboe <axboe@kernel.dk>
To: io-uring <io-uring@vger.kernel.org>
Subject: [PATCH] io_uring/io-wq: ensure workers are woken when io-wq context is exited
Date: Mon, 5 Jan 2026 07:45:54 -0700 [thread overview]
Message-ID: <79dbdfd9-636d-426c-8299-7becb588b19b@kernel.dk> (raw)
When io_wq_exit_start() is called, the IO_WQ_BIT_EXIT bit is set to
indicate to workers that the async context is going away. When that
happens, any worker alive should be woken up. If that doesn't happen,
then io-wq worker exit may take as long as WORKER_IDLE_TIMEOUT, which
is set to 5 seconds by default.
Cc: stable@vger.kernel.org # v6.18+
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
Didn't fully bisect where this problem got introduced, it's sometime
between 6.12 and 6.15. But as 6.18 is the latest maintained stable
that has the issue, just mark it for 6.18.
diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c
index cd13d8aac3d2..fd8c15ad2b97 100644
--- a/io_uring/io-wq.c
+++ b/io_uring/io-wq.c
@@ -1294,6 +1294,14 @@ static bool io_task_work_match(struct callback_head *cb, void *data)
void io_wq_exit_start(struct io_wq *wq)
{
set_bit(IO_WQ_BIT_EXIT, &wq->state);
+
+ for (int i = 0; i < IO_WQ_ACCT_NR; i++) {
+ struct io_wq_acct *acct = &wq->acct[i];
+
+ raw_spin_lock(&acct->workers_lock);
+ io_acct_for_each_worker(acct, io_wq_worker_wake, NULL);
+ raw_spin_unlock(&acct->workers_lock);
+ }
}
static void io_wq_cancel_tw_create(struct io_wq *wq)
--
Jens Axboe
next reply other threads:[~2026-01-05 14:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 14:45 Jens Axboe [this message]
2026-01-05 15:45 ` [PATCH] io_uring/io-wq: ensure workers are woken when io-wq context is exited Jens Axboe
[not found] ` <CAAZOf259y2HOVrCaqMvvegowp9fFgZSx2hqeP=ZfHJ2D9GyUUg@mail.gmail.com>
2026-01-05 15:54 ` Jens Axboe
[not found] ` <CAAZOf25R3eg0YzyWAyT0hhqe-mngcESKrweoyVcuR6n+7L1Usg@mail.gmail.com>
2026-01-05 17:59 ` 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=79dbdfd9-636d-426c-8299-7becb588b19b@kernel.dk \
--to=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
/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