mirror of
https://github.com/torvalds/linux
synced 2024-10-04 18:33:42 +00:00
io_uring: use unpin_user_pages() where appropriate
There are a few cases of open-rolled loops around unpin_user_page(), use the generic helper instead. Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
87585b0575
commit
18595c0a58
|
@ -2630,13 +2630,11 @@ void io_pages_unmap(void *ptr, struct page ***pages, unsigned short *npages,
|
||||||
static void io_pages_free(struct page ***pages, int npages)
|
static void io_pages_free(struct page ***pages, int npages)
|
||||||
{
|
{
|
||||||
struct page **page_array = *pages;
|
struct page **page_array = *pages;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!page_array)
|
if (!page_array)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < npages; i++)
|
unpin_user_pages(page_array, npages);
|
||||||
unpin_user_page(page_array[i]);
|
|
||||||
kvfree(page_array);
|
kvfree(page_array);
|
||||||
*pages = NULL;
|
*pages = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -455,8 +455,8 @@ static int io_pin_pbuf_ring(struct io_uring_buf_reg *reg,
|
||||||
struct io_buffer_list *bl)
|
struct io_buffer_list *bl)
|
||||||
{
|
{
|
||||||
struct io_uring_buf_ring *br = NULL;
|
struct io_uring_buf_ring *br = NULL;
|
||||||
int nr_pages, ret, i;
|
|
||||||
struct page **pages;
|
struct page **pages;
|
||||||
|
int nr_pages, ret;
|
||||||
|
|
||||||
pages = io_pin_pages(reg->ring_addr,
|
pages = io_pin_pages(reg->ring_addr,
|
||||||
flex_array_size(br, bufs, reg->ring_entries),
|
flex_array_size(br, bufs, reg->ring_entries),
|
||||||
|
@ -492,8 +492,7 @@ static int io_pin_pbuf_ring(struct io_uring_buf_reg *reg,
|
||||||
bl->is_mmap = 0;
|
bl->is_mmap = 0;
|
||||||
return 0;
|
return 0;
|
||||||
error_unpin:
|
error_unpin:
|
||||||
for (i = 0; i < nr_pages; i++)
|
unpin_user_pages(pages, nr_pages);
|
||||||
unpin_user_page(pages[i]);
|
|
||||||
kvfree(pages);
|
kvfree(pages);
|
||||||
vunmap(br);
|
vunmap(br);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue