diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2021-10-09 23:14:40 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-10-19 05:49:55 -0600 |
commit | a46be971edb69fe4b1dcc4359c3ddf9127629dab (patch) | |
tree | 7125540c7c3c6a5bdbb61139b5ad52e5e35b34a3 /fs/io_uring.c | |
parent | def77acf4396a850544b41623d7720ea3a2674a9 (diff) | |
download | lwn-a46be971edb69fe4b1dcc4359c3ddf9127629dab.tar.gz lwn-a46be971edb69fe4b1dcc4359c3ddf9127629dab.zip |
io_uring: optimise io_req_set_rsrc_node()
io_req_set_rsrc_node() reloads loads req->ctx, however it's already in
registers in all use cases, so better to pass it as a parameter.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/67a25557b8a51e90bfd578447a6f1671911b05ae.1633817310.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 141bfe720ce2..6486ebf31866 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1174,10 +1174,9 @@ static inline void io_req_set_refcount(struct io_kiocb *req) __io_req_set_refcount(req, 1); } -static inline void io_req_set_rsrc_node(struct io_kiocb *req) +static inline void io_req_set_rsrc_node(struct io_kiocb *req, + struct io_ring_ctx *ctx) { - struct io_ring_ctx *ctx = req->ctx; - if (!req->fixed_rsrc_refs) { req->fixed_rsrc_refs = &ctx->rsrc_node->refs; percpu_ref_get(req->fixed_rsrc_refs); @@ -2828,7 +2827,7 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, if (req->opcode == IORING_OP_READ_FIXED || req->opcode == IORING_OP_WRITE_FIXED) { req->imu = NULL; - io_req_set_rsrc_node(req); + io_req_set_rsrc_node(req, ctx); } req->rw.addr = READ_ONCE(sqe->addr); @@ -6757,7 +6756,7 @@ static inline struct file *io_file_get_fixed(struct io_ring_ctx *ctx, file_ptr &= ~FFS_MASK; /* mask in overlapping REQ_F and FFS bits */ req->flags |= (file_ptr << REQ_F_NOWAIT_READ_BIT); - io_req_set_rsrc_node(req); + io_req_set_rsrc_node(req, ctx); return file; } |