From nobody Wed Jun 17 06:11:07 2026 Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E36B5202F71; Mon, 27 Apr 2026 16:59:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.136.29.106 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777309165; cv=none; b=M4Sir6Y+IdXdg7MRsH9UhvDUNUUXwopbn3fgk/ktK/ANwxYNI6e1aVhiW1o2DuKxCoLo622jrH05W3gDLhpokE0OkUWiriK6Tu8PCNdK69/Z4jG5eQ6VZsZUrKTvjMTf/s83OpDvg4UBcJAmASQNt8p/pX5qjNSus/id//wv0bc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777309165; c=relaxed/simple; bh=aw+fq0Zozzvh1eMl1V8KLqFVvenFKuQ48rCw8Zm6nIw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=FThCRNQjYiQMIIb01DOmYg0BKfwvnn9hUsHCYdUm+nrpcKCeZwpcvyCUT5XfaPD2o2zANQmUzCeNnttMQ68g7d7gG2yUVciHVwXb0Uyxo0LKz0/Q+YjZWAbhnDRoVez2VU0S1PrkiXNgDyw+HX9ptfE4ZkIrOtVnZzLcRLtW73U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=proxmox.com; spf=pass smtp.mailfrom=proxmox.com; arc=none smtp.client-ip=94.136.29.106 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=proxmox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proxmox.com Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 18EA34B4C4; Mon, 27 Apr 2026 18:59:15 +0200 (CEST) From: Fiona Ebner To: io-uring@vger.kernel.org Cc: axboe@kernel.dk, linux-kernel@vger.kernel.org, t.lamprecht@proxmox.com Subject: [PATCH] io_uring/wait: make check for pending io consider cached task references Date: Mon, 27 Apr 2026 18:58:49 +0200 Message-ID: <20260427165910.683941-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1777309059520 Content-Type: text/plain; charset="utf-8" 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) =20 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; } =20 static enum hrtimer_restart io_cqring_timer_wakeup(struct hrtimer *timer) --=20 2.47.3