Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring: only initialize io_kiocb rsrc_nodes when needed

Add the empty node initializing to the preinit part of the io_kiocb
allocation, and reset them if they have been used.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

+10 -4
+2 -2
io_uring/io_uring.c
··· 947 947 static void io_preinit_req(struct io_kiocb *req, struct io_ring_ctx *ctx) 948 948 { 949 949 req->ctx = ctx; 950 + req->rsrc_nodes[IORING_RSRC_FILE] = rsrc_empty_node; 951 + req->rsrc_nodes[IORING_RSRC_BUFFER] = rsrc_empty_node; 950 952 req->link = NULL; 951 953 req->async_data = NULL; 952 954 /* not necessary, but safer to zero */ ··· 2034 2032 req->flags = (__force io_req_flags_t) sqe_flags; 2035 2033 req->cqe.user_data = READ_ONCE(sqe->user_data); 2036 2034 req->file = NULL; 2037 - req->rsrc_nodes[IORING_RSRC_FILE] = rsrc_empty_node; 2038 - req->rsrc_nodes[IORING_RSRC_BUFFER] = rsrc_empty_node; 2039 2035 req->task = current; 2040 2036 req->cancel_seq_set = false; 2041 2037
+8 -2
io_uring/rsrc.h
··· 81 81 82 82 static inline void io_req_put_rsrc_nodes(struct io_kiocb *req) 83 83 { 84 - io_put_rsrc_node(req->rsrc_nodes[IORING_RSRC_FILE]); 85 - io_put_rsrc_node(req->rsrc_nodes[IORING_RSRC_BUFFER]); 84 + if (req->rsrc_nodes[IORING_RSRC_FILE] != rsrc_empty_node) { 85 + io_put_rsrc_node(req->rsrc_nodes[IORING_RSRC_FILE]); 86 + req->rsrc_nodes[IORING_RSRC_FILE] = rsrc_empty_node; 87 + } 88 + if (req->rsrc_nodes[IORING_RSRC_BUFFER] != rsrc_empty_node) { 89 + io_put_rsrc_node(req->rsrc_nodes[IORING_RSRC_BUFFER]); 90 + req->rsrc_nodes[IORING_RSRC_BUFFER] = rsrc_empty_node; 91 + } 86 92 } 87 93 88 94 static inline void io_req_assign_rsrc_node(struct io_kiocb *req,