summaryrefslogtreecommitdiffstats
path: root/io_uring/rsrc.h
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2023-04-04 14:39:46 +0200
committerJens Axboe <axboe@kernel.dk>2023-04-04 17:30:39 +0200
commit8e15c0e71b8ae64fb7163532860f8d608165281f (patch)
tree27f9f09c08c03720ae10393588ce70a57e8c82be /io_uring/rsrc.h
parentio_uring/rsrc: use non-pcpu refcounts for nodes (diff)
downloadlinux-8e15c0e71b8ae64fb7163532860f8d608165281f.tar.xz
linux-8e15c0e71b8ae64fb7163532860f8d608165281f.zip
io_uring/rsrc: keep cached refs per node
We cache refs of the current node (i.e. ctx->rsrc_node) in ctx->rsrc_cached_refs. We'll be moving away from atomics, so move the cached refs in struct io_rsrc_node for now. It's a prep patch and shouldn't change anything in practise. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/9edc3669c1d71b06c2dca78b2b2b8bb9292738b9.1680576071.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to '')
-rw-r--r--io_uring/rsrc.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index 1467b31843bc..950535e2b9f4 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -43,6 +43,7 @@ struct io_rsrc_node {
struct io_rsrc_data *rsrc_data;
struct llist_node llist;
bool done;
+ int cached_refs;
};
struct io_mapped_ubuf {
@@ -56,7 +57,7 @@ struct io_mapped_ubuf {
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_refs_refill(struct io_ring_ctx *ctx);
+void io_rsrc_refs_refill(struct io_ring_ctx *ctx, struct io_rsrc_node *node);
void io_wait_rsrc_data(struct io_rsrc_data *data);
void io_rsrc_node_destroy(struct io_rsrc_node *ref_node);
void io_rsrc_refs_drop(struct io_ring_ctx *ctx);
@@ -128,17 +129,18 @@ static inline void io_req_put_rsrc_locked(struct io_kiocb *req,
if (node) {
if (node == ctx->rsrc_node)
- ctx->rsrc_cached_refs++;
+ node->cached_refs++;
else
io_rsrc_put_node(node, 1);
}
}
-static inline void io_charge_rsrc_node(struct io_ring_ctx *ctx)
+static inline void io_charge_rsrc_node(struct io_ring_ctx *ctx,
+ struct io_rsrc_node *node)
{
- ctx->rsrc_cached_refs--;
- if (unlikely(ctx->rsrc_cached_refs < 0))
- io_rsrc_refs_refill(ctx);
+ node->cached_refs--;
+ if (unlikely(node->cached_refs < 0))
+ io_rsrc_refs_refill(ctx, node);
}
static inline void io_req_set_rsrc_node(struct io_kiocb *req,
@@ -151,7 +153,7 @@ static inline void io_req_set_rsrc_node(struct io_kiocb *req,
lockdep_assert_held(&ctx->uring_lock);
req->rsrc_node = ctx->rsrc_node;
- io_charge_rsrc_node(ctx);
+ io_charge_rsrc_node(ctx, ctx->rsrc_node);
io_ring_submit_unlock(ctx, issue_flags);
}
}