From: Jens Axboe <axboe@kernel.dk>
To: io-uring <io-uring@vger.kernel.org>
Subject: [PATCH] io_uring/uring_cmd: skip inline completion cleanup if unlocked
Date: Wed, 6 May 2026 05:04:42 -0600 [thread overview]
Message-ID: <2469b617-3b4d-442f-84a9-7d1136d84065@kernel.dk> (raw)
If the call path to __io_uring_cmd_done() is not locked, then we
cannot recycle the uring_cmd to our allocation cache. Check for
that and skip it, and let the normal locked completion flushing
do the cleanup.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
This effectively defeats proper cache recyling for uring_cmd opcodes,
with the fix it's working fine again.
diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c
index 42be1be5b132..35e2aa8b9446 100644
--- a/io_uring/uring_cmd.c
+++ b/io_uring/uring_cmd.c
@@ -166,7 +166,9 @@ void __io_uring_cmd_done(struct io_uring_cmd *ioucmd, s32 ret, u64 res2,
req->cqe.flags |= IORING_CQE_F_32;
io_req_set_cqe32_extra(req, res2, 0);
}
- io_req_uring_cleanup(req, issue_flags);
+ /* defer cleanup if not locked, otherwise cache recyling is skipped */
+ if (!(issue_flags & IO_URING_F_UNLOCKED))
+ io_req_uring_cleanup(req, issue_flags);
if (req->flags & REQ_F_IOPOLL) {
/* order with io_iopoll_req_issued() checking ->iopoll_complete */
smp_store_release(&req->iopoll_completed, 1);
@@ -211,6 +213,7 @@ int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
ac = io_uring_alloc_async_data(&req->ctx->cmd_cache, req);
if (!ac)
return -ENOMEM;
+ req->flags |= REQ_F_NEED_CLEANUP;
ioucmd->sqe = sqe;
return 0;
}
--
Jens Axboe
next reply other threads:[~2026-05-06 11:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 11:04 Jens Axboe [this message]
2026-05-06 16:14 ` [PATCH] io_uring/uring_cmd: skip inline completion cleanup if unlocked Caleb Sander Mateos
2026-05-06 16:24 ` Jens Axboe
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=2469b617-3b4d-442f-84a9-7d1136d84065@kernel.dk \
--to=axboe@kernel.dk \
--cc=io-uring@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox