sparse-vmemmap: at boot, map struct pages only for the memory that exists. A 128 MB section costs 2 MB of memory map (one 2 MB page on x86-64) even in a 32 MB guest, which needs 512 KiB. --- a/mm/sparse-vmemmap.c 2026-10-04 20:42:00.433388796 +0200 +++ b/mm/sparse-vmemmap.c 2026-10-04 20:42:00.475388539 +0200 @@ -570,6 +570,16 @@ !IS_ALIGNED(nr_pages, PAGES_PER_SUBSECTION))) return NULL; + /* + * PLANCK: at boot a section gets a memory map only for the pages that exist. A 128 MB section + * otherwise costs 2 MB of struct page however little RAM the machine has; a 32 MB guest needs + * 512 KiB. The shorter range also makes x86 map it with base pages instead of one 2 MB page. + * mm_init.c must not touch the map above max_pfn (see memmap_init). + */ + if (system_state == SYSTEM_BOOTING && !altmap && !pgmap && + pfn < max_pfn && pfn + nr_pages > max_pfn) + end = start + ALIGN(max_pfn - pfn, PAGES_PER_SUBSECTION) * sizeof(struct page); + if (vmemmap_can_optimize(altmap, pgmap)) r = vmemmap_populate_compound_pages(pfn, start, end, nid, pgmap); else --- a/mm/mm_init.c 2026-10-04 20:42:00.436388777 +0200 +++ b/mm/mm_init.c 2026-10-04 20:42:00.476388533 +0200 @@ -994,7 +994,10 @@ * Append the pages in this hole to the highest zone in the last * node. */ -#ifdef CONFIG_SPARSEMEM +#ifdef CONFIG_SPARSEMEM_VMEMMAP + /* PLANCK: the memory map ends at the subsection holding max_pfn (__populate_section_memmap) */ + end_pfn = round_up(end_pfn, PAGES_PER_SUBSECTION); +#elif defined(CONFIG_SPARSEMEM) end_pfn = round_up(end_pfn, PAGES_PER_SECTION); #else end_pfn = round_up(end_pfn, MAX_ORDER_NR_PAGES);