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/kbuf: simplify __io_put_kbuf

As a preparation step remove an optimisation from __io_put_kbuf() trying
to use the locked cache. With that __io_put_kbuf_list() is only used
with ->io_buffers_comp, and we remove the explicit list argument.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/1b7f1394ec4afc7f96b35a61f5992e27c49fd067.1738724373.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
dc39fb10 dd4fbb11

+6 -27
+3 -23
io_uring/kbuf.c
··· 70 70 71 71 void __io_put_kbuf(struct io_kiocb *req, int len, unsigned issue_flags) 72 72 { 73 - /* 74 - * We can add this buffer back to two lists: 75 - * 76 - * 1) The io_buffers_cache list. This one is protected by the 77 - * ctx->uring_lock. If we already hold this lock, add back to this 78 - * list as we can grab it from issue as well. 79 - * 2) The io_buffers_comp list. This one is protected by the 80 - * ctx->completion_lock. 81 - * 82 - * We migrate buffers from the comp_list to the issue cache list 83 - * when we need one. 84 - */ 85 - if (issue_flags & IO_URING_F_UNLOCKED) { 86 - struct io_ring_ctx *ctx = req->ctx; 87 - 88 - spin_lock(&ctx->completion_lock); 89 - __io_put_kbuf_list(req, len, &ctx->io_buffers_comp); 90 - spin_unlock(&ctx->completion_lock); 91 - } else { 92 - lockdep_assert_held(&req->ctx->uring_lock); 93 - 94 - __io_put_kbuf_list(req, len, &req->ctx->io_buffers_cache); 95 - } 73 + spin_lock(&req->ctx->completion_lock); 74 + __io_put_kbuf_list(req, len); 75 + spin_unlock(&req->ctx->completion_lock); 96 76 } 97 77 98 78 static void __user *io_provided_buffer_select(struct io_kiocb *req, size_t *len,
+3 -4
io_uring/kbuf.h
··· 160 160 return ret; 161 161 } 162 162 163 - static inline void __io_put_kbuf_list(struct io_kiocb *req, int len, 164 - struct list_head *list) 163 + static inline void __io_put_kbuf_list(struct io_kiocb *req, int len) 165 164 { 166 165 if (req->flags & REQ_F_BUFFER_RING) { 167 166 __io_put_kbuf_ring(req, len, 1); 168 167 } else { 169 168 req->buf_index = req->kbuf->bgid; 170 - list_add(&req->kbuf->list, list); 169 + list_add(&req->kbuf->list, &req->ctx->io_buffers_comp); 171 170 req->flags &= ~REQ_F_BUFFER_SELECTED; 172 171 } 173 172 } ··· 178 179 179 180 spin_lock(&req->ctx->completion_lock); 180 181 /* len == 0 is fine here, non-ring will always drop all of it */ 181 - __io_put_kbuf_list(req, 0, &req->ctx->io_buffers_comp); 182 + __io_put_kbuf_list(req, 0); 182 183 spin_unlock(&req->ctx->completion_lock); 183 184 } 184 185