From: Jens Axboe <axboe@kernel.dk>
To: stable@vger.kernel.org
Subject: [PATCH 6.6.y 06/19] io_uring: cleanup handle_tw_list() calling convention
Date: Sat, 21 Nov 2026 21:30:36 +0000 [thread overview]
Message-ID: <20261121213049.1788332-7-axboe@kernel.dk> (raw)
In-Reply-To: <20261121213049.1788332-1-axboe@kernel.dk>
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@kernel.dk>
[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()]
---
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 8bbcab4d1d7c..96474d9ebef8 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.55.0
next prev parent reply other threads:[~2026-11-21 21:31 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 21:30 [PATCH 6.6.y 00/19] io_uring fixes for 6.6-stable Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 01/19] io_uring: enable toggle of iowait usage when waiting on CQEs Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 02/19] io_uring: fail soft links on negative IOU_COMPLETE results Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 03/19] io_uring/rw: fail soft links on IOPOLL short or error IO Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 04/19] io_uring/timeout: don't rearm a multishot timeout on cancel Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 05/19] io_uring/rsrc: keep the old file when a file update fails Jens Axboe
2026-11-21 21:30 ` Jens Axboe [this message]
2026-11-21 21:30 ` [PATCH 6.6.y 07/19] io_uring: pass in counter to handle_tw_list() rather than return it Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 08/19] io_uring/sqpoll: manage task_work privately Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 09/19] io_uring: wake SQPOLL task when task_work is added to an empty queue Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 10/19] io_uring/sqpoll: use the correct check for pending task_work Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 11/19] io_uring/sqpoll: early exit thread if task_context wasn't allocated Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 12/19] io_uring/sqpoll: ensure that normal task_work is also run timely Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 13/19] io_uring: signal SQPOLL task_work with TWA_SIGNAL_NO_IPI Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 14/19] io_uring/sqpoll: ensure task state is TASK_RUNNING when running task_work Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 15/19] io_uring: don't touch sqd->thread off tw add Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 16/19] io_uring/sqpoll: zero sqd->thread on tctx errors Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 17/19] io_uring/sqpoll: Increase task_work submission batch size Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 18/19] io_uring: fix task_work add use-after-free with SQPOLL Jens Axboe
2026-11-21 21:30 ` [PATCH 6.6.y 19/19] io_uring/sqpoll: do the return-to-userspace work in the SQPOLL thread Jens Axboe
2026-11-22 3:38 ` [PATCH 6.6.y 00/19] io_uring fixes for 6.6-stable Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261121213049.1788332-7-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.