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: use vmap() for ring mapping

This is the last holdout which does odd page checking, convert it to
vmap just like what is done for the non-mmap path.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

+9 -29
+9 -29
io_uring/io_uring.c
··· 63 63 #include <linux/sched/mm.h> 64 64 #include <linux/uaccess.h> 65 65 #include <linux/nospec.h> 66 - #include <linux/highmem.h> 67 66 #include <linux/fsnotify.h> 68 67 #include <linux/fadvise.h> 69 68 #include <linux/task_work.h> ··· 2656 2657 struct page **page_array; 2657 2658 unsigned int nr_pages; 2658 2659 void *page_addr; 2659 - int ret, i, pinned; 2660 + int ret, pinned; 2660 2661 2661 2662 *npages = 0; 2662 2663 ··· 2678 2679 goto free_pages; 2679 2680 } 2680 2681 2681 - page_addr = page_address(page_array[0]); 2682 - for (i = 0; i < nr_pages; i++) { 2683 - ret = -EINVAL; 2684 - 2685 - /* 2686 - * Can't support mapping user allocated ring memory on 32-bit 2687 - * archs where it could potentially reside in highmem. Just 2688 - * fail those with -EINVAL, just like we did on kernels that 2689 - * didn't support this feature. 2690 - */ 2691 - if (PageHighMem(page_array[i])) 2692 - goto free_pages; 2693 - 2694 - /* 2695 - * No support for discontig pages for now, should either be a 2696 - * single normal page, or a huge page. Later on we can add 2697 - * support for remapping discontig pages, for now we will 2698 - * just fail them with EINVAL. 2699 - */ 2700 - if (page_address(page_array[i]) != page_addr) 2701 - goto free_pages; 2702 - page_addr += PAGE_SIZE; 2682 + page_addr = vmap(page_array, nr_pages, VM_MAP, PAGE_KERNEL); 2683 + if (page_addr) { 2684 + *pages = page_array; 2685 + *npages = nr_pages; 2686 + return page_addr; 2703 2687 } 2704 - 2705 - *pages = page_array; 2706 - *npages = nr_pages; 2707 - return page_to_virt(page_array[0]); 2708 - 2688 + ret = -ENOMEM; 2709 2689 free_pages: 2710 2690 io_pages_free(&page_array, pinned > 0 ? pinned : 0); 2711 2691 return ERR_PTR(ret); ··· 2714 2736 ctx->n_ring_pages = 0; 2715 2737 io_pages_free(&ctx->sqe_pages, ctx->n_sqe_pages); 2716 2738 ctx->n_sqe_pages = 0; 2739 + vunmap(ctx->rings); 2740 + vunmap(ctx->sq_sqes); 2717 2741 } 2718 2742 2719 2743 ctx->rings = NULL;