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: add helper calculating region byte size

There has been type related issues with region size calculation, add an
utility helper function that returns the size and handles type
conversions right.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
4aed5b4e 21bd7b14

+7 -2
+2 -2
io_uring/memmap.c
··· 134 134 static int io_region_pin_pages(struct io_mapped_region *mr, 135 135 struct io_uring_region_desc *reg) 136 136 { 137 - unsigned long size = mr->nr_pages << PAGE_SHIFT; 137 + size_t size = io_region_size(mr); 138 138 struct page **pages; 139 139 int nr_pages; 140 140 ··· 154 154 unsigned long mmap_offset) 155 155 { 156 156 gfp_t gfp = GFP_KERNEL_ACCOUNT | __GFP_ZERO | __GFP_NOWARN; 157 - size_t size = (size_t) mr->nr_pages << PAGE_SHIFT; 157 + size_t size = io_region_size(mr); 158 158 unsigned long nr_allocated; 159 159 struct page **pages; 160 160
+5
io_uring/memmap.h
··· 43 43 *dst_region = *src_region; 44 44 } 45 45 46 + static inline size_t io_region_size(struct io_mapped_region *mr) 47 + { 48 + return (size_t) mr->nr_pages << PAGE_SHIFT; 49 + } 50 + 46 51 #endif