From: Jens Axboe <axboe@kernel.dk>
To: io-uring@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 4/7] io_uring/rsrc: get rid of io_rsrc_node allocation cache
Date: Sat, 26 Oct 2024 16:08:29 -0600 [thread overview]
Message-ID: <20241026222348.90331-5-axboe@kernel.dk> (raw)
In-Reply-To: <20241026222348.90331-1-axboe@kernel.dk>
It's not going to be needed in the fast path going forward, so kill it
off.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
include/linux/io_uring_types.h | 3 ---
io_uring/io_uring.c | 6 +-----
io_uring/rsrc.c | 24 +++++++++---------------
3 files changed, 10 insertions(+), 23 deletions(-)
diff --git a/include/linux/io_uring_types.h b/include/linux/io_uring_types.h
index 93111d87a88a..60541da6b875 100644
--- a/include/linux/io_uring_types.h
+++ b/include/linux/io_uring_types.h
@@ -362,9 +362,6 @@ struct io_ring_ctx {
struct io_rsrc_data *file_data;
struct io_rsrc_data *buf_data;
- /* protected by ->uring_lock */
- struct io_alloc_cache rsrc_node_cache;
-
u32 pers_next;
struct xarray personalities;
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 95ad74993a3f..8e24373c1c98 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -312,9 +312,7 @@ static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p)
INIT_LIST_HEAD(&ctx->sqd_list);
INIT_LIST_HEAD(&ctx->cq_overflow_list);
INIT_LIST_HEAD(&ctx->io_buffers_cache);
- ret = io_alloc_cache_init(&ctx->rsrc_node_cache, IO_NODE_ALLOC_CACHE_MAX,
- sizeof(struct io_rsrc_node));
- ret |= io_alloc_cache_init(&ctx->apoll_cache, IO_POLL_ALLOC_CACHE_MAX,
+ ret = io_alloc_cache_init(&ctx->apoll_cache, IO_POLL_ALLOC_CACHE_MAX,
sizeof(struct async_poll));
ret |= io_alloc_cache_init(&ctx->netmsg_cache, IO_ALLOC_CACHE_MAX,
sizeof(struct io_async_msghdr));
@@ -358,7 +356,6 @@ static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p)
free_ref:
percpu_ref_exit(&ctx->refs);
err:
- io_alloc_cache_free(&ctx->rsrc_node_cache, kfree);
io_alloc_cache_free(&ctx->apoll_cache, kfree);
io_alloc_cache_free(&ctx->netmsg_cache, io_netmsg_cache_free);
io_alloc_cache_free(&ctx->rw_cache, io_rw_cache_free);
@@ -2743,7 +2740,6 @@ static __cold void io_ring_ctx_free(struct io_ring_ctx *ctx)
WARN_ON_ONCE(!list_empty(&ctx->ltimeout_list));
- io_alloc_cache_free(&ctx->rsrc_node_cache, kfree);
if (ctx->mm_account) {
mmdrop(ctx->mm_account);
ctx->mm_account = NULL;
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 9822222a7acb..322749c7dee9 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -13,7 +13,6 @@
#include <uapi/linux/io_uring.h>
#include "io_uring.h"
-#include "alloc_cache.h"
#include "openclose.h"
#include "rsrc.h"
#include "memmap.h"
@@ -132,19 +131,15 @@ struct io_rsrc_node *io_rsrc_node_alloc(struct io_ring_ctx *ctx,
{
struct io_rsrc_node *node;
- node = io_alloc_cache_get(&ctx->rsrc_node_cache);
- if (!node) {
- node = kzalloc(sizeof(*node), GFP_KERNEL);
- if (!node)
- return NULL;
+ node = kzalloc(sizeof(*node), GFP_KERNEL);
+ if (node) {
+ node->ctx = ctx;
+ node->refs = 1;
+ node->type = type;
+ node->index = index;
+ node->tag = 0;
+ node->rsrc = NULL;
}
-
- node->ctx = ctx;
- node->refs = 1;
- node->type = type;
- node->index = index;
- node->tag = 0;
- node->rsrc = NULL;
return node;
}
@@ -493,8 +488,7 @@ void io_free_rsrc_node(struct io_rsrc_node *node)
break;
}
- if (!io_alloc_cache_put(&ctx->rsrc_node_cache, node))
- kfree(node);
+ kfree(node);
}
static void __io_sqe_files_unregister(struct io_ring_ctx *ctx)
--
2.45.2
next prev parent reply other threads:[~2024-10-26 22:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-26 22:08 [PATCHSET RFC 0/7] Rewrite rsrc node handling Jens Axboe
2024-10-26 22:08 ` [PATCH 1/7] io_uring/rsrc: move strct io_fixed_file to rsrc.h header Jens Axboe
2024-10-26 22:08 ` [PATCH 2/7] io_uring: specify freeptr usage for SLAB_TYPESAFE_BY_RCU io_kiocb cache Jens Axboe
2024-10-26 22:08 ` [PATCH 3/7] io_uring/rsrc: get rid of per-ring io_rsrc_node list Jens Axboe
2024-10-26 22:08 ` Jens Axboe [this message]
2024-10-26 22:08 ` [PATCH 5/7] io_uring/rsrc: add an empty io_rsrc_node for sparse buffer entries Jens Axboe
2024-10-26 22:08 ` [PATCH 6/7] io_uring: only initialize io_kiocb rsrc_nodes when needed Jens Axboe
2024-10-26 22:08 ` [PATCH 7/7] io_uring/rsrc: unify file and buffer resource tables 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=20241026222348.90331-5-axboe@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 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.