summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2025-04-19 18:47:04 +0100
committerJens Axboe <axboe@kernel.dk>2025-04-21 05:10:04 -0600
commitea76925614189bdcb6571e2ea8de68af409ebd56 (patch)
treeacbb924e3bbefc707a38c514ecd779bfbecfe535
parent8a2dacd49f1d19f4e3a4ebc99d11622cafd1659e (diff)
io_uring/rsrc: use unpin_user_folio
We want to have a full folio to be left pinned but with only one reference, for that we "unpin" all but the first page with unpin_user_pages(), which can be confusing. There is a new helper to achieve that called unpin_user_folio(), so use that. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Reviewed-by: Anuj Gupta <anuj20.g@samsung.com> Link: https://lore.kernel.org/r/e0b2be8f9ea68f6b351ec3bb046f04f437f68491.1745083025.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--io_uring/rsrc.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 107064c9c6fc..6bf8dff4adf3 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -699,10 +699,9 @@ static bool io_coalesce_buffer(struct page ***pages, int *nr_pages,
* The pages are bound to the folio, it doesn't
* actually unpin them but drops all but one reference,
* which is usually put down by io_buffer_unmap().
- * Note, needs a better helper.
*/
if (data->nr_pages_head > 1)
- unpin_user_pages(&page_array[1], data->nr_pages_head - 1);
+ unpin_user_folio(page_folio(new_array[0]), data->nr_pages_head - 1);
j = data->nr_pages_head;
nr_pages_left -= data->nr_pages_head;
@@ -713,7 +712,7 @@ static bool io_coalesce_buffer(struct page ***pages, int *nr_pages,
nr_unpin = min_t(unsigned int, nr_pages_left - 1,
data->nr_pages_mid - 1);
if (nr_unpin)
- unpin_user_pages(&page_array[j+1], nr_unpin);
+ unpin_user_folio(page_folio(new_array[i]), nr_unpin);
j += data->nr_pages_mid;
nr_pages_left -= data->nr_pages_mid;
}