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: introduce io_kbuf_drop_legacy()

io_kbuf_drop() is only used for legacy provided buffers, and so
__io_put_kbuf_list() is never called for REQ_F_BUFFER_RING. Remove the
dead branch out of __io_put_kbuf_list(), rename it into
io_kbuf_drop_legacy() and use it directly instead of io_kbuf_drop().

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

authored by

Pavel Begunkov and committed by
Jens Axboe
54e00d9a e150e70f

+13 -23
+1 -1
io_uring/io_uring.c
··· 397 397 static void io_clean_op(struct io_kiocb *req) 398 398 { 399 399 if (unlikely(req->flags & REQ_F_BUFFER_SELECTED)) 400 - io_kbuf_drop(req); 400 + io_kbuf_drop_legacy(req); 401 401 402 402 if (req->flags & REQ_F_NEED_CLEANUP) { 403 403 const struct io_cold_def *def = &io_cold_defs[req->opcode];
+10
io_uring/kbuf.c
··· 50 50 return xa_err(xa_store(&ctx->io_bl_xa, bgid, bl, GFP_KERNEL)); 51 51 } 52 52 53 + void io_kbuf_drop_legacy(struct io_kiocb *req) 54 + { 55 + if (WARN_ON_ONCE(!(req->flags & REQ_F_BUFFER_SELECTED))) 56 + return; 57 + req->buf_index = req->kbuf->bgid; 58 + req->flags &= ~REQ_F_BUFFER_SELECTED; 59 + kfree(req->kbuf); 60 + req->kbuf = NULL; 61 + } 62 + 53 63 bool io_kbuf_recycle_legacy(struct io_kiocb *req, unsigned issue_flags) 54 64 { 55 65 struct io_ring_ctx *ctx = req->ctx;
+2 -22
io_uring/kbuf.h
··· 75 75 int io_register_pbuf_status(struct io_ring_ctx *ctx, void __user *arg); 76 76 77 77 bool io_kbuf_recycle_legacy(struct io_kiocb *req, unsigned issue_flags); 78 + void io_kbuf_drop_legacy(struct io_kiocb *req); 78 79 79 80 struct io_mapped_region *io_pbuf_get_region(struct io_ring_ctx *ctx, 80 81 unsigned int bgid); ··· 159 158 return ret; 160 159 } 161 160 162 - static inline void __io_put_kbuf_list(struct io_kiocb *req, int len) 163 - { 164 - if (req->flags & REQ_F_BUFFER_RING) { 165 - __io_put_kbuf_ring(req, len, 1); 166 - } else { 167 - req->buf_index = req->kbuf->bgid; 168 - req->flags &= ~REQ_F_BUFFER_SELECTED; 169 - kfree(req->kbuf); 170 - req->kbuf = NULL; 171 - } 172 - } 173 - 174 - static inline void io_kbuf_drop(struct io_kiocb *req) 175 - { 176 - if (!(req->flags & (REQ_F_BUFFER_SELECTED|REQ_F_BUFFER_RING))) 177 - return; 178 - 179 - /* len == 0 is fine here, non-ring will always drop all of it */ 180 - __io_put_kbuf_list(req, 0); 181 - } 182 - 183 161 static inline unsigned int __io_put_kbufs(struct io_kiocb *req, int len, 184 162 int nbufs, unsigned issue_flags) 185 163 { ··· 172 192 if (!__io_put_kbuf_ring(req, len, nbufs)) 173 193 ret |= IORING_CQE_F_BUF_MORE; 174 194 } else { 175 - __io_put_kbuf_list(req, len); 195 + io_kbuf_drop_legacy(req); 176 196 } 177 197 return ret; 178 198 }