[to-be-updated] mm-vmalloc-map-contiguous-pages-in-batches-for-vmap-if-possible-fix.patch removed from -mm tree
Andrew Morton <[email protected]>
| Newsgroups | org.kernel.vger.mm-commits |
|---|---|
| Message-ID | <[email protected]> |
The quilt patch titled
Subject: mm/vmalloc: simplify vmap batching helper and limit scan by PFN alignment
has been removed from the -mm tree. Its filename was
mm-vmalloc-map-contiguous-pages-in-batches-for-vmap-if-possible-fix.patch
This patch was dropped because an updated version will be issued
------------------------------------------------------
From: Wen Jiang <[email protected]>
Subject: mm/vmalloc: simplify vmap batching helper and limit scan by PFN alignment
Date: Wed, 22 Jul 2026 16:58:41 +0800
Pass the current page pointer directly to the batching helper, and limit
the contiguous scan by PFN alignment before checking for a batch size.
This keeps the helper interface simpler and avoids scanning more pages
than can actually be mapped together.
Link: https://lore.kernel.org/[email protected]
Signed-off-by: Wen Jiang <[email protected]>
Suggested-by: David Hildenbrand (Arm) <[email protected]>
Cc: Andrew Donnellan <[email protected]>
Cc: Anshuman Khandual <[email protected]>
Cc: "Barry Song (Xiaomi)" <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Dev Jain <[email protected]>
Cc: Leo Yan <[email protected]>
Cc: Mike Rapoport <[email protected]>
Cc: Ryan Roberts <[email protected]>
Cc: "Uladzislau Rezki (Sony)" <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Xueyuan Chen <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---
mm/vmalloc.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
--- a/mm/vmalloc.c~mm-vmalloc-map-contiguous-pages-in-batches-for-vmap-if-possible-fix
+++ a/mm/vmalloc.c
@@ -3585,7 +3585,7 @@ static inline unsigned int vm_shift(pgpr
}
static inline int get_vmap_batch_order(struct page **pages,
- pgprot_t prot, unsigned int max_steps, unsigned int idx)
+ pgprot_t prot, unsigned int nr_pages)
{
unsigned long pfn;
unsigned int nr_contig;
@@ -3594,16 +3594,16 @@ static inline int get_vmap_batch_order(s
if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP))
return 0;
- nr_contig = num_pages_contiguous(&pages[idx], max_steps);
+ /* Limit nr_pages by pfn alignment */
+ pfn = page_to_pfn(*pages);
+ if (pfn > 0)
+ nr_pages = min_t(unsigned int, nr_pages, 1UL << __ffs(pfn));
+
+ nr_contig = num_pages_contiguous(pages, nr_pages);
if (nr_contig < 2)
return 0;
order = ilog2(nr_contig);
- pfn = page_to_pfn(pages[idx]);
-
- /* Limit order by pfn alignment */
- if (pfn > 0)
- order = min_t(int, order, __ffs(pfn));
if (vm_shift(prot, PAGE_SIZE << order) == PAGE_SHIFT)
return 0;
@@ -3614,8 +3614,8 @@ static inline int get_vmap_batch_order(s
static int vmap_pages_range_batched(unsigned long addr, unsigned long end,
pgprot_t prot, struct page **pages)
{
- unsigned int count = (end - addr) >> PAGE_SHIFT;
- unsigned int prev_shift = 0, idx = 0;
+ const unsigned int nr_pages = (end - addr) >> PAGE_SHIFT;
+ unsigned int prev_shift = 0, batch_start = 0;
unsigned long map_addr = addr, batch_end = addr;
int err;
@@ -3624,26 +3624,26 @@ static int vmap_pages_range_batched(unsi
if (err)
goto out;
- for (unsigned int i = 0; i < count; ) {
+ for (unsigned int i = 0; i < nr_pages; ) {
unsigned int shift = PAGE_SHIFT +
- get_vmap_batch_order(pages, prot, count - i, i);
+ get_vmap_batch_order(pages + i, prot, nr_pages - i);
if (!i)
prev_shift = shift;
if (shift != prev_shift) {
err = vmap_pages_range_noflush_walk(map_addr, batch_end,
- prot, pages + idx, prev_shift);
+ prot, pages + batch_start, prev_shift);
if (err)
goto out;
prev_shift = shift;
map_addr = batch_end;
- idx = i;
+ batch_start = i;
}
/*
- * Once small pages are encountered, the remaining pages
- * are likely small as well.
+ * Once we fail to batch pages, we expect to fail batching
+ * for all remaining pages, so just give up.
*/
if (shift == PAGE_SHIFT)
break;
@@ -3654,8 +3654,8 @@ static int vmap_pages_range_batched(unsi
/* Remaining */
if (map_addr < end)
- err = vmap_pages_range_noflush_walk(map_addr, end,
- prot, pages + idx, prev_shift);
+ err = vmap_pages_range_noflush_walk(map_addr, end, prot,
+ pages + batch_start, prev_shift);
out:
flush_cache_vmap(addr, end);
_
Patches currently in -mm which might be from [email protected] are