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

* Re: [PATCH] io_uring/wait: make check for pending io consider cached task references
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2026-04-27 17:18 UTC (permalink / raw)
  To: Fiona Ebner, io-uring; +Cc: linux-kernel, t.lamprecht

On 4/27/26 10:58 AM, Fiona Ebner wrote:
> 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>

Looks go to me! Just needs:

Cc: stable@vger.kernel.org
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.

-- 
Jens Axboe

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

* Re: [PATCH] io_uring/wait: make check for pending io consider cached task references
  2026-04-27 17:18 ` Jens Axboe
@ 2026-04-28  9:54   ` Fiona Ebner
  0 siblings, 0 replies; 3+ messages in thread
From: Fiona Ebner @ 2026-04-28  9:54 UTC (permalink / raw)
  To: Jens Axboe, io-uring; +Cc: linux-kernel, t.lamprecht

Am 27.04.26 um 7:17 PM schrieb Jens Axboe:
> On 4/27/26 10:58 AM, Fiona Ebner wrote:
>> 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>
> 
> Looks go to me! Just needs:
> 
> Cc: stable@vger.kernel.org
> 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!


^ permalink raw reply	[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