Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring: don't vmap single page regions

When io_check_coalesce_buffer() meets a single page buffer it bails out
and tells that it can be coalesced. That's fine for registered buffers
as io_coalesce_buffer() wouldn't change anything, but the region code
now uses the function to decided on whether to vmap the buffer or not.

Report that a single page buffer is trivially coalescable and let
io_sqe_buffer_register() to filter them.

Fixes: c4d0ac1c1567 ("io_uring/memmap: optimise single folio regions")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/cb83e053f318857068447d40c95becebcd8aeced.1733689833.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
de3b9e2e 2e6406a2

+5 -8
+5 -8
io_uring/rsrc.c
··· 675 675 unsigned int count = 1, nr_folios = 1; 676 676 int i; 677 677 678 - if (nr_pages <= 1) 679 - return false; 680 - 681 678 data->nr_pages_mid = folio_nr_pages(folio); 682 - if (data->nr_pages_mid == 1) 683 - return false; 684 - 685 679 data->folio_shift = folio_shift(folio); 680 + 686 681 /* 687 682 * Check if pages are contiguous inside a folio, and all folios have 688 683 * the same page count except for the head and tail. ··· 745 750 } 746 751 747 752 /* If it's huge page(s), try to coalesce them into fewer bvec entries */ 748 - if (io_check_coalesce_buffer(pages, nr_pages, &data)) 749 - coalesced = io_coalesce_buffer(&pages, &nr_pages, &data); 753 + if (nr_pages > 1 && io_check_coalesce_buffer(pages, nr_pages, &data)) { 754 + if (data.nr_pages_mid != 1) 755 + coalesced = io_coalesce_buffer(&pages, &nr_pages, &data); 756 + } 750 757 751 758 imu = kvmalloc(struct_size(imu, bvec, nr_pages), GFP_KERNEL); 752 759 if (!imu)