Skip to contentSkip to conversation

io_uring/io-wq: ensure workers are woken when io-wq context is exited

PATCH In review Jens Axboe 2 participants 4 messages Jan 5 2 messages not in the archive io_uring

lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 io_uring/io-wq: ensure workers are woken when io-wq context is exited

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.

---

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.

io_uring/io-wq.c +8 -0
index cd13d8aac3d2..fd8c15ad2b97 100644
@@ -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)
Signature · 1 line
Jens Axboe
author maintainer
#1 lore raw
Quoted 8 lines · Jens Axboe

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.

Fixes 751eedc4b4b7 ("io_uring/io-wq: move worker lists to struct io_wq_acct")
Signature · 1 line
Jens Axboe

A message that is not in the archive (sent off-list or not yet received): CAAZOf259y2HOVrCaqMvvegowp9fFgZSx2hqeP=ZfHJ2D9GyUUg@mail.gmail.com

author maintainer
#3 lore raw
Quoted 2 lines · David Kahurani

work-queue has a bug but I don't know who to report to.

Ok that's enough of your random and useless emails. Welcome to the block list. Though that just solves the problem for me, please just go away and stop responding to list emails all together or I'll get you blocked from lore as well.

Signature · 1 line
Jens Axboe

A message that is not in the archive (sent off-list or not yet received): CAAZOf25R3eg0YzyWAyT0hhqe-mngcESKrweoyVcuR6n+7L1Usg@mail.gmail.com

#5 lore raw

Wire that up!

Quoted 19 lines · David Kahurani

In what case I will,....

Assume a legal protocol.

Quoted 13 lines · Jens Axboe
Quoted 2 lines · David Kahurani

work-queue has a bug but I don't know who to report to.

Ok that's enough of your random and useless emails. Welcome to the block list. Though that just solves the problem for me, please just go away and stop responding to list emails all together or I'll get you blocked from lore as well.

--
Jens Axboe