io_uring: allow buffer recycling in READV
PATCH v2 1/1 io_uring: allow buffer recycling in READV
In commit 934447a603b2 ("io_uring: do not recycle buffer in READV") a temporary fix was put in io_kbuf_recycle to simply never recycle READV buffers.
Instead of that, rather treat READV with REQ_F_BUFFER_SELECTED the same as a READ with REQ_F_BUFFER_SELECTED. Since READV requires iov_len of 1 they are essentially the same.
In order to do this inside io_prep_rw() add some validation to check that it is in fact only length 1, and also extract the length of the buffer at prep time.
This allows removal of the io_iov_buffer_select codepaths as they are only used from the READV op.
---
since v1:
- no change, just rebased on latest 6.0 branch
io_uring/kbuf.h | 12 ----- io_uring/rw.c | 134 +++++++++++++++++++----------------------------- 2 files changed, 52 insertions(+), 94 deletions(-)
io_uring/kbuf.h +0 -12
@@ -86,18 +86,6 @@ static inline bool io_do_buffer_select(struct io_kiocb *req)static inline void io_kbuf_recycle (struct io_kiocb *req,unsigned issue_flags) { -/* -* READV uses fields in `struct io_rw` (len/addr) to stash the selected -* buffer data. However if that buffer is recycled the original request -* data stored in addr is lost. Therefore forbid recycling for now. -*/ -if (req->opcode ==IORING_OP_READV ) { -if ((req->flags &REQ_F_BUFFER_RING ) && req->buf_list) { - req->buf_list->head++; - req->buf_list =NULL ; - } -return ; - }if (req->flags &REQ_F_BUFFER_SELECTED )io_kbuf_recycle_legacy (req, issue_flags);if (req->flags &REQ_F_BUFFER_RING )
io_uring/rw.c +52 -82
164 lines not on this page · raw message
base-commit: 336d28a8f38013a069f2d46e73aaa1880ef17a47
Signature · 1 line
2.30.2
Quoted 4 lines · Dylan Yudaken
In commit
934447a603b2("io_uring: do not recycle buffer in READV") a temporary fix was put inio_kbuf_recycleto simply never recycle READV buffers.
Quoted 8 lines
Instead of that, rather treat READV with
REQ_F_BUFFER_SELECTEDthe same as a READ withREQ_F_BUFFER_SELECTED. Since READV requiresiov_lenof 1 they are essentially the same.
In order to do this insideio_prep_rw()add some validation to check that it is in fact only length 1, and also extract the length of the buffer at prep time.[...]
Applied, thanks!
[1/1] io_uring: allow buffer recycling in READV
commit: 8e966e46c38df6d4f45d2122e321b2d5982fcaf8
Best regards,
Signature · 1 line
Jens Axboe