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: don't store bgid in req->buf_index

Pass buffer group id into the rest of helpers via struct buf_sel_arg
and remove all reassignments of req->buf_index back to bgid. Now, it
only stores buffer indexes, and the group is provided by callers.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/3ea9fa08113ecb4d9224b943e7806e80a324bdf9.1743437358.git.asml.silence@gmail.com
Link: https://lore.kernel.org/io-uring/0c01d76ff12986c2f48614db8610caff8f78c869.1743500909.git.asml.silence@gmail.com/
[axboe: fold in patch from second link]
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
bd32923e c0e96505

+8 -11
+1 -2
include/linux/io_uring_types.h
··· 653 653 u8 iopoll_completed; 654 654 /* 655 655 * Can be either a fixed buffer index, or used with provided buffers. 656 - * For the latter, before issue it points to the buffer group ID, 657 - * and after selection it points to the buffer ID itself. 656 + * For the latter, it points to the selected buffer ID. 658 657 */ 659 658 u16 buf_index; 660 659
+4 -7
io_uring/kbuf.c
··· 92 92 { 93 93 if (WARN_ON_ONCE(!(req->flags & REQ_F_BUFFER_SELECTED))) 94 94 return; 95 - req->buf_index = req->kbuf->bgid; 96 95 req->flags &= ~REQ_F_BUFFER_SELECTED; 97 96 kfree(req->kbuf); 98 97 req->kbuf = NULL; ··· 109 110 bl = io_buffer_get_list(ctx, buf->bgid); 110 111 list_add(&buf->list, &bl->buf_list); 111 112 req->flags &= ~REQ_F_BUFFER_SELECTED; 112 - req->buf_index = buf->bgid; 113 113 114 114 io_ring_submit_unlock(ctx, issue_flags); 115 115 return true; ··· 300 302 int ret = -ENOENT; 301 303 302 304 io_ring_submit_lock(ctx, issue_flags); 303 - bl = io_buffer_get_list(ctx, req->buf_index); 305 + bl = io_buffer_get_list(ctx, arg->buf_group); 304 306 if (unlikely(!bl)) 305 307 goto out_unlock; 306 308 ··· 333 335 334 336 lockdep_assert_held(&ctx->uring_lock); 335 337 336 - bl = io_buffer_get_list(ctx, req->buf_index); 338 + bl = io_buffer_get_list(ctx, arg->buf_group); 337 339 if (unlikely(!bl)) 338 340 return -ENOENT; 339 341 ··· 353 355 struct io_buffer_list *bl = req->buf_list; 354 356 bool ret = true; 355 357 356 - if (bl) { 358 + if (bl) 357 359 ret = io_kbuf_commit(req, bl, len, nr); 358 - req->buf_index = bl->bgid; 359 - } 360 + 360 361 req->flags &= ~REQ_F_BUFFER_RING; 361 362 return ret; 362 363 }
+1 -1
io_uring/kbuf.h
··· 55 55 size_t max_len; 56 56 unsigned short nr_iovs; 57 57 unsigned short mode; 58 + unsigned buf_group; 58 59 }; 59 60 60 61 void __user *io_buffer_select(struct io_kiocb *req, size_t *len, ··· 95 94 * to monopolize the buffer. 96 95 */ 97 96 if (req->buf_list) { 98 - req->buf_index = req->buf_list->bgid; 99 97 req->flags &= ~(REQ_F_BUFFER_RING|REQ_F_BUFFERS_COMMIT); 100 98 return true; 101 99 }
+2 -1
io_uring/net.c
··· 190 190 sr->done_io = 0; 191 191 sr->retry = false; 192 192 sr->len = 0; /* get from the provided buffer */ 193 - req->buf_index = sr->buf_group; 194 193 } 195 194 196 195 static int io_net_import_vec(struct io_kiocb *req, struct io_async_msghdr *iomsg, ··· 567 568 .iovs = &kmsg->fast_iov, 568 569 .max_len = min_not_zero(sr->len, INT_MAX), 569 570 .nr_iovs = 1, 571 + .buf_group = sr->buf_group, 570 572 }; 571 573 572 574 if (kmsg->vec.iovec) { ··· 1056 1056 .iovs = &kmsg->fast_iov, 1057 1057 .nr_iovs = 1, 1058 1058 .mode = KBUF_MODE_EXPAND, 1059 + .buf_group = sr->buf_group, 1059 1060 }; 1060 1061 1061 1062 if (kmsg->vec.iovec) {