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 Signed-off-by: Thomas Lamprecht Signed-off-by: Fiona Ebner --- 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