[PATCH v2 1/2] mm/vmemmap: Add a post-population hook for architectures

From: Vivian Wang

Date: Thu Jun 04 2026 - 07:20:57 EST


section_activate() does not flush TLB after populating new vmemmap
pages. On most architectures, this is okay, however it is a problem on
RISC-V since there TLB caching non-present entries is permitted, which
causes spurious faults on some hardwares.

Add a hook vmemmap_populate_finalize() in __populate_section_memmap()
after population, to allow architectures to handle such situations as
needed.

No functional change intended for now, but a hook implementation for
RISC-V will be added in a later patch.

Signed-off-by: Vivian Wang <wangruikang@xxxxxxxxxxx>
---
mm/sparse-vmemmap.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
index 6eadb9d116e4..2a8b923fabe8 100644
--- a/mm/sparse-vmemmap.c
+++ b/mm/sparse-vmemmap.c
@@ -544,6 +544,12 @@ static int __meminit vmemmap_populate_compound_pages(unsigned long start_pfn,

#endif

+#ifndef vmemmap_populate_finalize
+static void __meminit vmemmap_populate_finalize(void)
+{
+}
+#endif
+
struct page * __meminit __populate_section_memmap(unsigned long pfn,
unsigned long nr_pages, int nid, struct vmem_altmap *altmap,
struct dev_pagemap *pgmap)
@@ -564,6 +570,8 @@ struct page * __meminit __populate_section_memmap(unsigned long pfn,
if (r < 0)
return NULL;

+ vmemmap_populate_finalize();
+
return pfn_to_page(pfn);
}


--
2.54.0