From: Keith Busch <kbusch@meta.com>
To: <viro@zeniv.linux.org.uk>, <axboe@kernel.dk>, <io-uring@vger.kernel.org>
Cc: <asml.silence@gmail.com>, <linux-fsdevel@vger.kernel.org>,
Keith Busch <kbusch@kernel.org>
Subject: [PATCH 2/4] io_uring: switch network send/recv to ITER_UBUF
Date: Mon, 7 Nov 2022 09:56:08 -0800 [thread overview]
Message-ID: <20221107175610.349807-3-kbusch@meta.com> (raw)
In-Reply-To: <20221107175610.349807-1-kbusch@meta.com>
From: Jens Axboe <axboe@kernel.dk>
This is more efficient than ITER_IOVEC.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[merged to 6.1]
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
io_uring/net.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/io_uring/net.c b/io_uring/net.c
index 9a07e79cc0e6..12c68b5ec62d 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -170,7 +170,7 @@ static int io_setup_async_msg(struct io_kiocb *req,
if (async_msg->msg.msg_name)
async_msg->msg.msg_name = &async_msg->addr;
/* if were using fast_iov, set it to the new one */
- if (!kmsg->free_iov) {
+ if (iter_is_iovec(&kmsg->msg.msg_iter) && !kmsg->free_iov) {
size_t fast_idx = kmsg->msg.msg_iter.iov - kmsg->fast_iov;
async_msg->msg.msg_iter.iov = &async_msg->fast_iov[fast_idx];
}
@@ -333,7 +333,6 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags)
struct sockaddr_storage __address;
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
struct msghdr msg;
- struct iovec iov;
struct socket *sock;
unsigned flags;
int min_ret = 0;
@@ -367,7 +366,7 @@ int io_send(struct io_kiocb *req, unsigned int issue_flags)
if (unlikely(!sock))
return -ENOTSOCK;
- ret = import_single_range(WRITE, sr->buf, sr->len, &iov, &msg.msg_iter);
+ ret = import_ubuf(WRITE, sr->buf, sr->len, &msg.msg_iter);
if (unlikely(ret))
return ret;
@@ -752,10 +751,7 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
}
}
- kmsg->fast_iov[0].iov_base = buf;
- kmsg->fast_iov[0].iov_len = len;
- iov_iter_init(&kmsg->msg.msg_iter, READ, kmsg->fast_iov, 1,
- len);
+ iov_iter_ubuf(&kmsg->msg.msg_iter, READ, buf, len);
}
flags = sr->msg_flags;
@@ -824,7 +820,6 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
struct msghdr msg;
struct socket *sock;
- struct iovec iov;
unsigned int cflags;
unsigned flags;
int ret, min_ret = 0;
@@ -849,7 +844,7 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
sr->buf = buf;
}
- ret = import_single_range(READ, sr->buf, len, &iov, &msg.msg_iter);
+ ret = import_ubuf(READ, sr->buf, len, &msg.msg_iter);
if (unlikely(ret))
goto out_free;
--
2.30.2
next prev parent reply other threads:[~2022-11-07 18:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-07 17:56 [PATCH 0/4] io_uring: use ITER_UBUF Keith Busch
2022-11-07 17:56 ` [PATCH 1/4] iov: add import_ubuf() Keith Busch
2022-11-08 6:55 ` Christoph Hellwig
2022-11-08 16:05 ` Keith Busch
2022-11-07 17:56 ` Keith Busch [this message]
2022-11-07 17:56 ` [PATCH 3/4] io_uring: use ubuf for single range imports for read/write Keith Busch
2022-11-07 17:56 ` [PATCH 4/4] iov_iter: move iter_ubuf check inside restore WARN Keith Busch
2022-11-08 6:54 ` [PATCH 0/4] io_uring: use ITER_UBUF Christoph Hellwig
2022-11-08 20:25 ` Keith Busch
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=20221107175610.349807-3-kbusch@meta.com \
--to=kbusch@meta.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=kbusch@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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.