summaryrefslogtreecommitdiff
path: root/io_uring/rsrc.h
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2023-04-18 14:06:36 +0100
committerJens Axboe <axboe@kernel.dk>2023-04-18 19:38:26 -0600
commitc376644fb915fbdea8c4a04f859d032a8be352fd (patch)
treeb861357c660c9f944a217dcb2be2c80ea8eee3dc /io_uring/rsrc.h
parent63fea89027ff4fd4f350b471ad5b9220d373eec5 (diff)
io_uring/rsrc: merge nodes and io_rsrc_put
struct io_rsrc_node carries a number of resources represented by struct io_rsrc_put. That was handy before for sync overhead ammortisation, but all complexity is gone and nodes are simple and lightweight. Let's allocate a separate node for each resource. Nodes and io_rsrc_put and not much different in size, and former are cached, so node allocation should work better. That also removes some overhead for nested iteration in io_rsrc_node_ref_zero() / __io_rsrc_put_work(). Another reason for the patch is that it greatly reduces complexity by moving io_rsrc_node_switch[_start]() inside io_queue_rsrc_removal(), so users don't have to care about it. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/c7d3a45b30cc14cd93700a710dd112edc703db98.1681822823.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/rsrc.h')
-rw-r--r--io_uring/rsrc.h22
1 files changed, 2 insertions, 20 deletions
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index 8ed3e6a65cf6..bad7103f5033 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -18,7 +18,6 @@ enum {
};
struct io_rsrc_put {
- struct list_head list;
u64 tag;
union {
void *rsrc;
@@ -43,17 +42,10 @@ struct io_rsrc_node {
struct io_cache_entry cache;
struct io_rsrc_data *rsrc_data;
};
- struct list_head node;
int refs;
-
- /*
- * Keeps a list of struct io_rsrc_put to be completed. Each entry
- * represents one rsrc (e.g. file or buffer), but all of them should've
- * came from the same table and so are of the same type.
- */
- struct list_head item_list;
- struct io_rsrc_put item;
int inline_items;
+ struct list_head node;
+ struct io_rsrc_put item;
};
struct io_mapped_ubuf {
@@ -68,11 +60,8 @@ void io_rsrc_put_tw(struct callback_head *cb);
void io_rsrc_node_ref_zero(struct io_rsrc_node *node);
void io_rsrc_put_work(struct work_struct *work);
void io_rsrc_node_destroy(struct io_ring_ctx *ctx, struct io_rsrc_node *ref_node);
-int __io_rsrc_node_switch_start(struct io_ring_ctx *ctx);
struct io_rsrc_node *io_rsrc_node_alloc(struct io_ring_ctx *ctx);
int io_queue_rsrc_removal(struct io_rsrc_data *data, unsigned idx, void *rsrc);
-void io_rsrc_node_switch(struct io_ring_ctx *ctx,
- struct io_rsrc_data *data_to_kill);
int io_import_fixed(int ddir, struct iov_iter *iter,
struct io_mapped_ubuf *imu,
@@ -109,13 +98,6 @@ static inline int io_scm_file_account(struct io_ring_ctx *ctx,
return __io_scm_file_account(ctx, file);
}
-static inline int io_rsrc_node_switch_start(struct io_ring_ctx *ctx)
-{
- if (unlikely(io_alloc_cache_empty(&ctx->rsrc_node_cache)))
- return __io_rsrc_node_switch_start(ctx);
- return 0;
-}
-
int io_register_files_update(struct io_ring_ctx *ctx, void __user *arg,
unsigned nr_args);
int io_register_rsrc_update(struct io_ring_ctx *ctx, void __user *arg,