Skip to contentSkip to conversation

small optimisations

PATCH In review Pavel Begunkov 2 participants 4 messages Sep 1, 2021 – Sep 2, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover small optimisations

I think it'd better to have at least the first patch in 5.15

Pavel Begunkov (2):
io_uring: don't disable kiocb_done() CQE batching
io_uring: prolong tctx_task_work() with flushing

 fs/io_uring.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.33.0
#1 lore raw

PATCH 1/2 io_uring: don't disable kiocb_done() CQE batching

Not passing issue_flags from kiocb_done() into __io_complete_rw() means that completion batching for this case is disabled, e.g. for most of buffered reads.

---
 fs/io_uring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/io_uring.c +1 -1
index ef0c7ecc03a0..14b074575eb6 100644
@@ -2656,7 +2656,7 @@ static void __io_complete_rw(struct io_kiocb *req, long res, long res2,
 {
 	if (__io_complete_rw_common(req, res))
 		return;
-	__io_req_complete(req, 0, req->result, io_put_rw_kbuf(req));
+	__io_req_complete(req, issue_flags, req->result, io_put_rw_kbuf(req));
 }
 
 static void io_complete_rw(struct kiocb *kiocb, long res, long res2)
Signature · 1 line
2.33.0
#2 lore raw

PATCH 2/2 io_uring: prolong tctx_task_work() with flushing

In reply to Pavel Begunkov

io_submit_flush_completions() may enqueue linked requests for task_work execution, so don't leave tctx_task_work() right after the tw list is exhausted, but try to flush and then retry.

---
 fs/io_uring.c | 3 +++
 1 file changed, 3 insertions(+)
fs/io_uring.c +3 -0
index 14b074575eb6..2bde732a1183 100644
@@ -2102,6 +2102,9 @@ static void tctx_task_work(struct callback_head *cb)
 	while (1) {
 		struct io_wq_work_node *node;
 
+		if (!tctx->task_list.first && locked && ctx->submit_state.compl_nr)
+			io_submit_flush_completions(ctx);
+
 		spin_lock_irq(&tctx->task_lock);
 		node = tctx->task_list.first;
 		INIT_WQ_LIST(&tctx->task_list);
Signature · 1 line
2.33.0
maintainer
#3 lore raw
In reply to Pavel Begunkov
Quoted 1 line · Pavel Begunkov

I think it'd better to have at least the first patch in 5.15

Let's just shove both in, they are minor enough.

Signature · 1 line
Jens Axboe