mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-04-13 09:59:31 +00:00
io_uring: kbuf: add comments for some tricky code
Add comments to explain why it is always under uring lock when incrementing head in __io_kbuf_recycle. And rectify one comemnt about kbuf consuming in iowq case. Signed-off-by: Hao Xu <howeyxu@tencent.com> Link: https://lore.kernel.org/r/20220617050429.94293-1-hao.xu@linux.dev Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
9ca9fb24d5
commit
f09c8643f0
1 changed files with 14 additions and 6 deletions
|
@ -52,6 +52,13 @@ void __io_kbuf_recycle(struct io_kiocb *req, unsigned issue_flags)
|
||||||
if (req->flags & REQ_F_BUFFER_RING) {
|
if (req->flags & REQ_F_BUFFER_RING) {
|
||||||
if (req->buf_list) {
|
if (req->buf_list) {
|
||||||
if (req->flags & REQ_F_PARTIAL_IO) {
|
if (req->flags & REQ_F_PARTIAL_IO) {
|
||||||
|
/*
|
||||||
|
* If we end up here, then the io_uring_lock has
|
||||||
|
* been kept held since we retrieved the buffer.
|
||||||
|
* For the io-wq case, we already cleared
|
||||||
|
* req->buf_list when the buffer was retrieved,
|
||||||
|
* hence it cannot be set here for that case.
|
||||||
|
*/
|
||||||
req->buf_list->head++;
|
req->buf_list->head++;
|
||||||
req->buf_list = NULL;
|
req->buf_list = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -163,12 +170,13 @@ static void __user *io_ring_buffer_select(struct io_kiocb *req, size_t *len,
|
||||||
if (issue_flags & IO_URING_F_UNLOCKED || !file_can_poll(req->file)) {
|
if (issue_flags & IO_URING_F_UNLOCKED || !file_can_poll(req->file)) {
|
||||||
/*
|
/*
|
||||||
* If we came in unlocked, we have no choice but to consume the
|
* If we came in unlocked, we have no choice but to consume the
|
||||||
* buffer here. This does mean it'll be pinned until the IO
|
* buffer here, otherwise nothing ensures that the buffer won't
|
||||||
* completes. But coming in unlocked means we're in io-wq
|
* get used by others. This does mean it'll be pinned until the
|
||||||
* context, hence there should be no further retry. For the
|
* IO completes, coming in unlocked means we're being called from
|
||||||
* locked case, the caller must ensure to call the commit when
|
* io-wq context and there may be further retries in async hybrid
|
||||||
* the transfer completes (or if we get -EAGAIN and must poll
|
* mode. For the locked case, the caller must call commit when
|
||||||
* or retry).
|
* the transfer completes (or if we get -EAGAIN and must poll of
|
||||||
|
* retry).
|
||||||
*/
|
*/
|
||||||
req->buf_list = NULL;
|
req->buf_list = NULL;
|
||||||
bl->head++;
|
bl->head++;
|
||||||
|
|
Loading…
Add table
Reference in a new issue