Skip to contentSkip to conversation

io_uring/wait: make check for pending io consider cached task references

PATCH In review Fiona Ebner 2 participants 4 messages Apr 27 – Oct 9 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io_uring/wait: make check for pending io consider cached task references

The io_uring task's inflight count also includes the reservations for task references from io_task_refs_refill(), not just in-flight requests. Thus, pending requests are present if the inflight count is larger than the number of cached references.

---
 io_uring/wait.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
io_uring/wait.c +7 -1
index 91df86ce0d18c..d9d4fe3b0f40c 100644
@@ -48,7 +48,13 @@ static bool current_pending_io(void)
 
 	if (!tctx)
 		return false;
-	return percpu_counter_read_positive(&tctx->inflight);
+	/*
+	 * tctx->inflight also includes the reservations for task references
+	 * from io_task_refs_refill(), not just in-flight requests. Thus,
+	 * pending requests are present if the inflight count is larger than the
+	 * number of cached references.
+	 */
+	return percpu_counter_read_positive(&tctx->inflight) > tctx->cached_refs;
 }
 
 static enum hrtimer_restart io_cqring_timer_wakeup(struct hrtimer *timer)
Signature · 1 line
2.47.3
maintainer
#1 lore raw
Quoted 8 lines · Fiona Ebner

The io_uring task's inflight count also includes the reservations for task references from io_task_refs_refill(), not just in-flight requests. Thus, pending requests are present if the inflight count is larger than the number of cached references.

Looks go to me! Just needs:

Fixes 7b72d661f1f2 ("io_uring: gate iowait schedule on having pending requests")

tags added, I will do that. Thanks for debugging this and sending a fix.

Signature · 1 line
Jens Axboe
#2 lore raw

Am 27.04.26 um 7:17 PM schrieb Jens Axboe:

Quoted 10 lines · Fiona Ebner
Quoted 8 lines

The io_uring task's inflight count also includes the reservations for task references from io_task_refs_refill(), not just in-flight requests. Thus, pending requests are present if the inflight count is larger than the number of cached references.

Quoted 7 lines

Looks go to me! Just needs:

Fixes 7b72d661f1f2 ("io_uring: gate iowait schedule on having pending requests")

tags added, I will do that. Thanks for debugging this and sending a fix.

Thank you!

#3 lore raw

Hi Jens,

Am 28.04.26 um 11:52 AM schrieb Fiona Ebner:

Quoted 13 lines

Am 27.04.26 um 7:17 PM schrieb Jens Axboe:

Quoted 12 lines · Fiona Ebner
Quoted 8 lines

The io_uring task's inflight count also includes the reservations for task references from io_task_refs_refill(), not just in-flight requests. Thus, pending requests are present if the inflight count is larger than the number of cached references.

Looks go to me! Just needs:

Quoted 7 lines
Quoted 5 lines
Fixes 7b72d661f1f2 ("io_uring: gate iowait schedule on having pending requests")

tags added, I will do that. Thanks for debugging this and sending a fix.

Thank you!

it seems like this change did not yet land in mainline kernels. Should I resend with the added tags? Or is there some remaining issue with the change?

Best Regards,
Fiona