From: Andrew Morton <akpm@linux-foundation.org>
To: Wen Jiang <jiangwenxiaomi@gmail.com>
Cc: catalin.marinas@arm.com, linux-mm@kvack.org, urezki@gmail.com,
will@kernel.org, Xueyuan.chen21@gmail.com, ajd@linux.ibm.com,
anshuman.khandual@arm.com, david@kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, rppt@kernel.org,
ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org,
Wen Jiang <jiangwen6@xiaomi.com>
Subject: Re: [PATCH v7 0/7] mm/vmalloc: Speed up ioremap, vmalloc and vmap with contiguous memory
Date: Wed, 15 Jul 2026 11:37:59 -0700 [thread overview]
Message-ID: <20260715113759.74d68fef26f1df0c6bbcc85c@linux-foundation.org> (raw)
In-Reply-To: <20260715120813.3609949-1-jiangwen6@xiaomi.com>
On Wed, 15 Jul 2026 20:08:06 +0800 Wen Jiang <jiangwenxiaomi@gmail.com> wrote:
> This patchset accelerates ioremap, vmalloc, and vmap when the memory
> is physically fully or partially contiguous. Two techniques are used:
Thanks, I've updated mm.git's mm-unstable branch to this version.
> Changes since v6:
> - Add a clarifying comment about the reuse of hugetlb helpers
> by non-hugetlbfs(vmalloc) mm code (patch 1)
> - Expand the arm64/vmalloc commit message and comment to clarify that
> multi-CONT_PTE_SIZE values are vmalloc mapping spans, not HugeTLB
> hstate sizes (patch 2)
> - Move the local steps variable change in vmap_pte_range() into the
> vmap_set_ptes() extraction patch (patch 3)
> - Propagate vmap_pages_pte_range() errors through the upper
> vmap_pages_*() levels instead of returning -ENOMEM for all failures
> (patch 4)
> - Add a preparatory vm_shift() helper patch before the batching patch
> (patch 5)
> - Guard the PFN alignment clamp in get_vmap_batch_order() against PFN 0
> before calling __ffs() (patch 6)
> - Fix kmsan_vmap_pages_range_noflush() indentation in the batching path
> (patch 6)
Here's how v7 altered mm.git:
arch/arm64/include/asm/vmalloc.h | 2 +
arch/arm64/mm/hugetlbpage.c | 5 ++++
mm/vmalloc.c | 31 ++++++++++++++++-------------
3 files changed, 25 insertions(+), 13 deletions(-)
--- a/arch/arm64/include/asm/vmalloc.h~b
+++ a/arch/arm64/include/asm/vmalloc.h
@@ -29,6 +29,8 @@ static inline unsigned long arch_vmap_pt
* If the block is at least CONT_PTE_SIZE in size, and is naturally
* aligned in both virtual and physical space, then we can pte-map the
* block using the PTE_CONT bit for more efficient use of the TLB.
+ * The returned mapping size may cover multiple CONT_PTE_SIZE blocks,
+ * capped below PMD_SIZE.
*/
if (max_page_shift < CONT_PTE_SHIFT)
return PAGE_SIZE;
--- a/arch/arm64/mm/hugetlbpage.c~b
+++ a/arch/arm64/mm/hugetlbpage.c
@@ -94,6 +94,11 @@ static int find_num_contig(struct mm_str
return CONT_PTES;
}
+/*
+ * num_contig_ptes(), set_huge_pte_at() and arch_make_huge_pte() can be
+ * used by non-hugetlbfs(vmalloc) mm code to set multiple huge mappings
+ * at the PTE level.
+ */
static inline int num_contig_ptes(unsigned long size, size_t *pgsize)
{
int contig_ptes = 1;
--- a/mm/vmalloc.c~b
+++ a/mm/vmalloc.c
@@ -616,6 +616,7 @@ static int vmap_pages_pmd_range(pud_t *p
{
pmd_t *pmd;
unsigned long next;
+ int err;
pmd = pmd_alloc_track(&init_mm, pud, addr, mask);
if (!pmd)
@@ -642,8 +643,9 @@ static int vmap_pages_pmd_range(pud_t *p
}
}
- if (vmap_pages_pte_range(pmd, addr, next, prot, pages, nr, mask, shift))
- return -ENOMEM;
+ err = vmap_pages_pte_range(pmd, addr, next, prot, pages, nr, mask, shift);
+ if (err)
+ return err;
} while (pmd++, addr = next, addr != end);
return 0;
}
@@ -654,14 +656,16 @@ static int vmap_pages_pud_range(p4d_t *p
{
pud_t *pud;
unsigned long next;
+ int err;
pud = pud_alloc_track(&init_mm, p4d, addr, mask);
if (!pud)
return -ENOMEM;
do {
next = pud_addr_end(addr, end);
- if (vmap_pages_pmd_range(pud, addr, next, prot, pages, nr, mask, shift))
- return -ENOMEM;
+ err = vmap_pages_pmd_range(pud, addr, next, prot, pages, nr, mask, shift);
+ if (err)
+ return err;
} while (pud++, addr = next, addr != end);
return 0;
}
@@ -672,14 +676,16 @@ static int vmap_pages_p4d_range(pgd_t *p
{
p4d_t *p4d;
unsigned long next;
+ int err;
p4d = p4d_alloc_track(&init_mm, pgd, addr, mask);
if (!p4d)
return -ENOMEM;
do {
next = p4d_addr_end(addr, end);
- if (vmap_pages_pud_range(p4d, addr, next, prot, pages, nr, mask, shift))
- return -ENOMEM;
+ err = vmap_pages_pud_range(p4d, addr, next, prot, pages, nr, mask, shift);
+ if (err)
+ return err;
} while (p4d++, addr = next, addr != end);
return 0;
}
@@ -3591,6 +3597,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)
{
+ unsigned long pfn;
unsigned int nr_contig;
int order;
@@ -3602,9 +3609,11 @@ static inline int get_vmap_batch_order(s
return 0;
order = ilog2(nr_contig);
+ pfn = page_to_pfn(pages[idx]);
/* Limit order by pfn alignment */
- order = min_t(int, order, __ffs(page_to_pfn(pages[idx])));
+ if (pfn > 0)
+ order = min_t(int, order, __ffs(pfn));
if (vm_shift(prot, PAGE_SIZE << order) == PAGE_SHIFT)
return 0;
@@ -3621,7 +3630,7 @@ static int vmap_pages_range_batched(unsi
int err;
err = kmsan_vmap_pages_range_noflush(addr, end, prot, pages,
- PAGE_SHIFT, GFP_KERNEL);
+ PAGE_SHIFT, GFP_KERNEL);
if (err)
goto out;
@@ -4199,11 +4208,7 @@ void *__vmalloc_node_range_noprof(unsign
* supporting them.
*/
- if (arch_vmap_pmd_supported(prot) && size >= PMD_SIZE)
- shift = PMD_SHIFT;
- else
- shift = arch_vmap_pte_supported_shift(size);
-
+ shift = vm_shift(prot, size);
align = max(original_align, 1UL << shift);
}
_
prev parent reply other threads:[~2026-07-15 18:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 12:08 [PATCH v7 0/7] mm/vmalloc: Speed up ioremap, vmalloc and vmap with contiguous memory Wen Jiang
2026-07-15 12:08 ` [PATCH v7 1/7] arm64/hugetlb: Extend batching of multiple CONT_PTE in a single PTE setup Wen Jiang
2026-07-15 12:08 ` [PATCH v7 2/7] arm64/vmalloc: Allow arch_vmap_pte_range_map_size to batch multiple CONT_PTE Wen Jiang
2026-07-15 12:08 ` [PATCH v7 3/7] mm/vmalloc: Extract vmap_set_ptes() to consolidate PTE mapping logic Wen Jiang
2026-07-15 12:08 ` [PATCH v7 4/7] mm/vmalloc: Extend page table walk to support larger page_shift sizes and eliminate page table rewalk Wen Jiang
2026-07-15 12:08 ` [PATCH v7 5/7] mm/vmalloc: Extract vm_shift() to consolidate mapping shift selection Wen Jiang
2026-07-15 12:08 ` [PATCH v7 6/7] mm/vmalloc: map contiguous pages in batches for vmap() if possible Wen Jiang
2026-07-15 12:08 ` [PATCH v7 7/7] mm/vmalloc: align vm_area so vmap() can batch mappings Wen Jiang
2026-07-15 18:37 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260715113759.74d68fef26f1df0c6bbcc85c@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=Xueyuan.chen21@gmail.com \
--cc=ajd@linux.ibm.com \
--cc=anshuman.khandual@arm.com \
--cc=baohua@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=jiangwen6@xiaomi.com \
--cc=jiangwenxiaomi@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=urezki@gmail.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox