]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
io_uring/rsrc: use unpin_user_folio
authorPavel Begunkov <asml.silence@gmail.com>
Sat, 19 Apr 2025 17:47:04 +0000 (18:47 +0100)
committerJens Axboe <axboe@kernel.dk>
Mon, 21 Apr 2025 11:10:04 +0000 (05:10 -0600)
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>
io_uring/rsrc.c

index 107064c9c6fc2f7a45b21891de566bd1fa95388f..6bf8dff4adf3b857e8abc5cce21a4d5df715b7c8 100644 (file)
@@ -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;
        }