From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com
Subject: [PATCH 3/4] io_uring: early return for sparse buf table registration
Date: Fri, 4 Apr 2025 17:22:16 +0100 [thread overview]
Message-ID: <11655e617b90ee11bf95bf59b2cdc433d9448056.1743783348.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1743783348.git.asml.silence@gmail.com>
We don't need to do anything after io_rsrc_data_alloc() if the goal is
to create an empty buffer table, so just return earlier and clean up the
rest of io_sqe_buffers_register(). It should be particularly nice with
IORING_RSRC_REGISTER_SPARSE.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/rsrc.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index d5e29536466c..958eee7b4a47 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -867,28 +867,28 @@ int io_sqe_buffers_register(struct io_ring_ctx *ctx, void __user *arg,
if (ret)
return ret;
- if (!arg)
- memset(iov, 0, sizeof(*iov));
+ if (!arg) {
+ ctx->buf_table = data;
+ return 0;
+ }
for (i = 0; i < nr_args; i++) {
struct io_rsrc_node *node;
u64 tag = 0;
- if (arg) {
- uvec = (struct iovec __user *) arg;
- iov = iovec_from_user(uvec, 1, 1, &fast_iov, ctx->compat);
- if (IS_ERR(iov)) {
- ret = PTR_ERR(iov);
- break;
- }
- ret = io_buffer_validate(iov);
- if (ret)
- break;
- if (ctx->compat)
- arg += sizeof(struct compat_iovec);
- else
- arg += sizeof(struct iovec);
+ uvec = (struct iovec __user *) arg;
+ iov = iovec_from_user(uvec, 1, 1, &fast_iov, ctx->compat);
+ if (IS_ERR(iov)) {
+ ret = PTR_ERR(iov);
+ break;
}
+ ret = io_buffer_validate(iov);
+ if (ret)
+ break;
+ if (ctx->compat)
+ arg += sizeof(struct compat_iovec);
+ else
+ arg += sizeof(struct iovec);
if (tags) {
if (copy_from_user(&tag, &tags[i], sizeof(tag))) {
--
2.48.1
next prev parent reply other threads:[~2025-04-04 16:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-04 16:22 [PATCH 0/4] buffer table registration cleanup Pavel Begunkov
2025-04-04 16:22 ` [PATCH 1/4] io_uring/rsrc: avoid assigning buf table on failure Pavel Begunkov
2025-04-04 16:22 ` [PATCH 2/4] io_uring: deduplicate node tagging Pavel Begunkov
2025-04-04 16:22 ` Pavel Begunkov [this message]
2025-04-04 16:22 ` [PATCH 4/4] io_uring: reuse buffer updates for registration Pavel Begunkov
2025-04-04 16:38 ` Jens Axboe
2025-04-04 21:38 ` Pavel Begunkov
2025-04-04 22:00 ` 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=11655e617b90ee11bf95bf59b2cdc433d9448056.1743783348.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--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