summaryrefslogtreecommitdiffstats
path: root/io_uring/rsrc.h
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-11-03 16:46:07 +0100
committerJens Axboe <axboe@kernel.dk>2024-11-06 21:55:36 +0100
commit6f94cbc29adacc15007c5a16295052e674099282 (patch)
treee7cd3fa78367dedba9c456a43e871af6a7250dca /io_uring/rsrc.h
parentio_uring/rsrc: encode node type and ctx together (diff)
downloadlinux-6f94cbc29adacc15007c5a16295052e674099282.tar.xz
linux-6f94cbc29adacc15007c5a16295052e674099282.zip
io_uring/rsrc: split io_kiocb node type assignments
Currently the io_rsrc_node assignment in io_kiocb is an array of two pointers, as two nodes may be assigned to a request - one file node, and one buffer node. However, the buffer node can co-exist with the provided buffers, as currently it's not supported to use both provided and registered buffers at the same time. This crucially brings struct io_kiocb down to 4 cache lines again, as before it spilled into the 5th cacheline. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/rsrc.h')
-rw-r--r--io_uring/rsrc.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index 9a8fac31fa49..bc3a863b14bb 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -95,10 +95,14 @@ static inline bool io_reset_rsrc_node(struct io_rsrc_data *data, int index)
static inline void io_req_put_rsrc_nodes(struct io_kiocb *req)
{
- io_put_rsrc_node(req->rsrc_nodes[IORING_RSRC_FILE]);
- io_put_rsrc_node(req->rsrc_nodes[IORING_RSRC_BUFFER]);
- req->rsrc_nodes[IORING_RSRC_FILE] = NULL;
- req->rsrc_nodes[IORING_RSRC_BUFFER] = NULL;
+ if (req->file_node) {
+ io_put_rsrc_node(req->file_node);
+ req->file_node = NULL;
+ }
+ if (req->flags & REQ_F_BUF_NODE) {
+ io_put_rsrc_node(req->buf_node);
+ req->buf_node = NULL;
+ }
}
static inline struct io_ring_ctx *io_rsrc_node_ctx(struct io_rsrc_node *node)
@@ -111,11 +115,11 @@ static inline int io_rsrc_node_type(struct io_rsrc_node *node)
return node->ctx_ptr & IORING_RSRC_TYPE_MASK;
}
-static inline void io_req_assign_rsrc_node(struct io_kiocb *req,
+static inline void io_req_assign_rsrc_node(struct io_rsrc_node **dst_node,
struct io_rsrc_node *node)
{
node->refs++;
- req->rsrc_nodes[io_rsrc_node_type(node)] = node;
+ *dst_node = node;
}
int io_files_update(struct io_kiocb *req, unsigned int issue_flags);