From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379504; b=F/tPr5dH6wTsecAeKwgREaLxFMxFEGqusIeWpTFXliV0jnebRcz6Y64n9VCjVoMo/cgd tqULfoQxgk4G8uRWyXfqE/G2zE4Pa+ciwAhcUFDo6wKPkwr8aTM3pmVQLrWdKKJwQ7+Uc d1NuGTg2XWdVzZVYxDat8FcwrGQ+4R/iz8ciDu2gdF8iqcfKgRlxWUgXtfA/2tMJgWEmS JwkIaw7cZ242LWUoiC5PASSn9vJlmEDm5S4tNfUW5Uk3bkVFHbMq+kY2RxfbShTi7hufi l7vqf+Tmt2BHy5N0k+OKp+lvhnl0FSvBNdyT3uiEia3fBVEJJ5aPevi3H7HyzLZslrQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379504; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=0nKGE9ND/5B8gmN1Ku88w19N6KznO40SNBDGZV269WQ=; b=1M4im3Nlj5AHw3zg+P4EH+pskfn+LvD6KBOdcpKLFL8yNAwJTiwswY7FcoxHM3Gz9AgI UDuWauo6DzK95I+mWg/jy/LnFu7yPMk28OKgRBLCL8GjUaD/SSQPkPFUdCSV8IocZjgZc Gn4mMJQ1c/Kj4aw9HcS0el1QWRDxl0GAP3hRfzqDYXrQuKrkTj+bkZt8cPtsP7wLAhKJy yPTKvAXJazXMHbWTUwfM9YwjmpU6yz6Ahqvh82XiSGY1tRUBeTRt7qsRe+0GNqJA55LWq 90BaYfuMeqN2q3eMQQQ53GCOIRXutbaZTvAg3F3ETH9Ux+oAWRSwW1lzOzzWrhCNRIA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=UD4iJdo4; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E20A606A322; Fri, 4 Dec 2026 10:18:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=UD4iJdo4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBC0A1F000C2; Fri, 4 Dec 2026 10:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379504; bh=0nKGE9ND/5B8gmN1Ku88w19N6KznO40SNBDGZV269WQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UD4iJdo4QGmrJ3vNNvHcRUfOzBpTDNnrm3iE3W9AkzUV089fKuwOu4/ONkxn8wPZk Cv32ahAhfDjwqnTh4JMGvsDsnixxNiaobrKk9s834txiW7s0JKJbgyulq68oAEyp1+ /25n4aW6esgy8pTP1IGJQVuFPo76EXVTkEROpPZs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jens Axboe , Sasha Levin Subject: [PATCH 6.6 0021/1167] io_uring: cleanup handle_tw_list() calling convention Date: Fri, 4 Dec 2026 18:50:48 +0900 Message-ID: <20261204100702.598320625@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jens Axboe Commit 42c0905f0cac9a86d2cb8138665a6d62ea607078 upstream. Now that we don't loop around task_work anymore, there's no point in maintaining the ring and locked state outside of handle_tw_list(). Get rid of passing in those pointers (and pointers to pointers) and just do the management internally in handle_tw_list(). Signed-off-by: Jens Axboe [axboe: 6.6 runs normal task_work in LIFO order, as it doesn't have 170539bdf109 ("io_uring: handle traditional task_work in FIFO order"), so call handle_tw_list() without llist_reverse_order()] Signed-off-by: Sasha Levin --- io_uring/io_uring.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 8bbcab4d1d7c4..96474d9ebef82 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1197,10 +1197,10 @@ static void ctx_flush_and_put(struct io_ring_ctx *ctx, struct io_tw_state *ts) percpu_ref_put(&ctx->refs); } -static unsigned int handle_tw_list(struct llist_node *node, - struct io_ring_ctx **ctx, - struct io_tw_state *ts) +static unsigned int handle_tw_list(struct llist_node *node) { + struct io_ring_ctx *ctx = NULL; + struct io_tw_state ts = { }; unsigned int count = 0; do { @@ -1210,25 +1210,26 @@ static unsigned int handle_tw_list(struct llist_node *node, prefetch(container_of(next, struct io_kiocb, io_task_work.node)); - if (req->ctx != *ctx) { - ctx_flush_and_put(*ctx, ts); - *ctx = req->ctx; + if (req->ctx != ctx) { + ctx_flush_and_put(ctx, &ts); + ctx = req->ctx; /* if not contended, grab and improve batching */ - ts->locked = mutex_trylock(&(*ctx)->uring_lock); - percpu_ref_get(&(*ctx)->refs); + ts.locked = mutex_trylock(&ctx->uring_lock); + percpu_ref_get(&ctx->refs); } INDIRECT_CALL_2(req->io_task_work.func, io_poll_task_func, io_req_rw_complete, - req, ts); + req, &ts); node = next; count++; if (unlikely(need_resched())) { - ctx_flush_and_put(*ctx, ts); - *ctx = NULL; + ctx_flush_and_put(ctx, &ts); + ctx = NULL; cond_resched(); } } while (node); + ctx_flush_and_put(ctx, &ts); return count; } @@ -1277,8 +1278,6 @@ static __cold void io_fallback_tw(struct io_uring_task *tctx, bool sync) void tctx_task_work(struct callback_head *cb) { - struct io_tw_state ts = {}; - struct io_ring_ctx *ctx = NULL; struct io_uring_task *tctx = container_of(cb, struct io_uring_task, task_work); struct llist_node *node; @@ -1291,9 +1290,7 @@ void tctx_task_work(struct callback_head *cb) node = llist_del_all(&tctx->task_list); if (node) - count = handle_tw_list(node, &ctx, &ts); - - ctx_flush_and_put(ctx, &ts); + count = handle_tw_list(node); /* relaxed read is enough as only the task itself sets ->in_cancel */ if (unlikely(atomic_read(&tctx->in_cancel))) -- 2.53.0