From: Dylan Yudaken <[email protected]>
To: Jens Axboe <[email protected]>,
Pavel Begunkov <[email protected]>,
<[email protected]>
Cc: <[email protected]>, Dylan Yudaken <[email protected]>
Subject: [PATCH for-next 4/4] io_uring: move netmsg recycling into io_uring cleanup
Date: Fri, 8 Jul 2022 11:18:38 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Specifically will be useful for multishot as the lifetime of a request is
a bit more complicated, but generally makes things a bit neater.
Signed-off-by: Dylan Yudaken <[email protected]>
---
io_uring/net.c | 10 ++++------
io_uring/net.h | 1 +
io_uring/opdef.c | 2 ++
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/io_uring/net.c b/io_uring/net.c
index 997c17512694..c1cbafe96c63 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -98,18 +98,18 @@ static bool io_net_retry(struct socket *sock, int flags)
return sock->type == SOCK_STREAM || sock->type == SOCK_SEQPACKET;
}
-static void io_netmsg_recycle(struct io_kiocb *req, unsigned int issue_flags)
+bool io_netmsg_recycle(struct io_kiocb *req)
{
struct io_async_msghdr *hdr = req->async_data;
- if (!hdr || issue_flags & IO_URING_F_UNLOCKED)
- return;
-
if (io_alloc_cache_store(&req->ctx->netmsg_cache)) {
hlist_add_head(&hdr->cache_list, &req->ctx->netmsg_cache.list);
req->async_data = NULL;
req->flags &= ~REQ_F_ASYNC_DATA;
+ return true;
}
+
+ return false;
}
static struct io_async_msghdr *io_recvmsg_alloc_async(struct io_kiocb *req,
@@ -261,7 +261,6 @@ int io_sendmsg(struct io_kiocb *req, unsigned int issue_flags)
if (kmsg->free_iov)
kfree(kmsg->free_iov);
req->flags &= ~REQ_F_NEED_CLEANUP;
- io_netmsg_recycle(req, issue_flags);
if (ret >= 0)
ret += sr->done_io;
else if (sr->done_io)
@@ -583,7 +582,6 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
/* fast path, check for non-NULL to avoid function call */
if (kmsg->free_iov)
kfree(kmsg->free_iov);
- io_netmsg_recycle(req, issue_flags);
req->flags &= ~REQ_F_NEED_CLEANUP;
if (ret > 0)
ret += sr->done_io;
diff --git a/io_uring/net.h b/io_uring/net.h
index 576efb602c7f..c5a897e61f10 100644
--- a/io_uring/net.h
+++ b/io_uring/net.h
@@ -44,6 +44,7 @@ int io_connect_prep_async(struct io_kiocb *req);
int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
int io_connect(struct io_kiocb *req, unsigned int issue_flags);
+bool io_netmsg_recycle(struct io_kiocb *req);
void io_flush_netmsg_cache(struct io_ring_ctx *ctx);
#else
static inline void io_flush_netmsg_cache(struct io_ring_ctx *ctx)
diff --git a/io_uring/opdef.c b/io_uring/opdef.c
index a7b84b43e6c2..b525e37f397a 100644
--- a/io_uring/opdef.c
+++ b/io_uring/opdef.c
@@ -153,6 +153,7 @@ const struct io_op_def io_op_defs[] = {
.issue = io_sendmsg,
.prep_async = io_sendmsg_prep_async,
.cleanup = io_sendmsg_recvmsg_cleanup,
+ .recycle_async = io_netmsg_recycle,
#else
.prep = io_eopnotsupp_prep,
#endif
@@ -170,6 +171,7 @@ const struct io_op_def io_op_defs[] = {
.issue = io_recvmsg,
.prep_async = io_recvmsg_prep_async,
.cleanup = io_sendmsg_recvmsg_cleanup,
+ .recycle_async = io_netmsg_recycle,
#else
.prep = io_eopnotsupp_prep,
#endif
--
2.30.2
next prev parent reply other threads:[~2022-07-08 18:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-08 18:18 [PATCH for-next 0/4] io_uring: multishot recv cleanups Dylan Yudaken
2022-07-08 18:18 ` [PATCH for-next 1/4] io_uring: fix multishot ending when not polled Dylan Yudaken
2022-07-08 18:18 ` [PATCH for-next 2/4] io_uring: support 0 length iov in buffer select in compat Dylan Yudaken
2022-07-08 18:18 ` [PATCH for-next 3/4] io-uring: add recycle_async to ops Dylan Yudaken
2022-07-08 18:18 ` Dylan Yudaken [this message]
2022-07-11 20:54 ` (subset) [PATCH for-next 0/4] io_uring: multishot recv cleanups Jens Axboe
2022-07-11 20:55 ` Jens Axboe
2022-07-12 8:32 ` Dylan Yudaken
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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