public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] io_uring/wait: make check for pending io consider cached task references
@ 2026-04-27 16:58 Fiona Ebner
  2026-04-27 17:18 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Fiona Ebner @ 2026-04-27 16:58 UTC (permalink / raw)
  To: io-uring; +Cc: axboe, linux-kernel, t.lamprecht

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.

Co-developed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 io_uring/wait.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/io_uring/wait.c b/io_uring/wait.c
index 91df86ce0d18c..d9d4fe3b0f40c 100644
--- a/io_uring/wait.c
+++ b/io_uring/wait.c
@@ -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)
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-28  9:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 16:58 [PATCH] io_uring/wait: make check for pending io consider cached task references Fiona Ebner
2026-04-27 17:18 ` Jens Axboe
2026-04-28  9:54   ` Fiona Ebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox