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: move locking into io_kbuf_drop()

Move the burden of locking out of the caller into io_kbuf_drop(), that
will help with furher refactoring.

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

authored by

Pavel Begunkov and committed by
Jens Axboe
dd4fbb11 9afe6847

+3 -6
+1 -4
io_uring/io_uring.c
··· 398 398 399 399 static void io_clean_op(struct io_kiocb *req) 400 400 { 401 - if (req->flags & REQ_F_BUFFER_SELECTED) { 402 - spin_lock(&req->ctx->completion_lock); 401 + if (unlikely(req->flags & REQ_F_BUFFER_SELECTED)) 403 402 io_kbuf_drop(req); 404 - spin_unlock(&req->ctx->completion_lock); 405 - } 406 403 407 404 if (req->flags & REQ_F_NEED_CLEANUP) { 408 405 const struct io_cold_def *def = &io_cold_defs[req->opcode];
+2 -2
io_uring/kbuf.h
··· 174 174 175 175 static inline void io_kbuf_drop(struct io_kiocb *req) 176 176 { 177 - lockdep_assert_held(&req->ctx->completion_lock); 178 - 179 177 if (!(req->flags & (REQ_F_BUFFER_SELECTED|REQ_F_BUFFER_RING))) 180 178 return; 181 179 180 + spin_lock(&req->ctx->completion_lock); 182 181 /* len == 0 is fine here, non-ring will always drop all of it */ 183 182 __io_put_kbuf_list(req, 0, &req->ctx->io_buffers_comp); 183 + spin_unlock(&req->ctx->completion_lock); 184 184 } 185 185 186 186 static inline unsigned int __io_put_kbufs(struct io_kiocb *req, int len,