[PATCH v2 22/28] arch, mm: consolidate initialization of nodes, zones and memory map
Mike Rapoport
rppt at kernel.org
Sun Jan 4 05:54:23 AEDT 2026
Hi,
On Sat, Jan 03, 2026 at 12:33:29AM +0100, Klara Modin wrote:
> On 2026-01-02 08:59:58 +0200, Mike Rapoport wrote:
> > From: "Mike Rapoport (Microsoft)" <rppt at kernel.org>
> >
> > To initialize node, zone and memory map data structures every architecture
> > calls free_area_init() during setup_arch() and passes it an array of zone
> > limits.
> >
> > Beside code duplication it creates "interesting" ordering cases between
> > allocation and initialization of hugetlb and the memory map. Some
> > architectures allocate hugetlb pages very early in setup_arch() in certain
> > cases, some only create hugetlb CMA areas in setup_arch() and sometimes
> > hugetlb allocations happen mm_core_init().
> >
> > With arch_zone_limits_init() helper available now on all architectures it
> > is no longer necessary to call free_area_init() from architecture setup
> > code. Rather core MM initialization can call arch_zone_limits_init() in a
> > single place.
> >
> > This allows to unify ordering of hugetlb vs memory map allocation and
> > initialization.
> >
> > Remove the call to free_area_init() from architecture specific code and
> > place it in a new mm_core_init_early() function that is called immediately
> > after setup_arch().
> >
> > After this refactoring it is possible to consolidate hugetlb allocations
> > and eliminate differences in ordering of hugetlb and memory map
> > initialization among different architectures.
> >
> > As the first step of this consolidation move hugetlb_bootmem_alloc() to
> > mm_core_early_init().
> >
> > Signed-off-by: Mike Rapoport (Microsoft) <rppt at kernel.org>
>
> This breaks boot on my Raspberry Pi 1. The reason seems to be the use of
> page_folio() when initializing the dynamically allocated zero page in
> arm, which doesn't work when free_area_init() hasn't been called yet.
I believe the reason is rather the use of virt_to_phys() that now happens
before the memory map is ready.
> The following oopses are generated:
>
> 8<--- cut here ---
> Unable to handle kernel paging request at virtual address 003dfb44 when read
> [003dfb44] *pgd=00000000
> Internal error: Oops: 5 [#1] ARM
> CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.19.0-rc3-03898-g7975b0084358 #451 NONE
> Hardware name: BCM2835
> PC is at paging_init (include/linux/page-flags.h:284 (discriminator 2) arch/arm/mm/mmu.c:1790 (discriminator 2))
> LR is at paging_init (arch/arm/mm/mmu.c:1789 (discriminator 1))
...
> 8<--- cut here ---
>
> and the second one repeats for some time afterwards.
>
> I experimented a little by allocating the zero page statically as many
> other arches do which fixes the issue as it does not need to be
> initialized at this point anymore, though I have no idea if that's
> appropriate.
Do you mean putting the zero in the BSS like, e.g. arm64? I don't see a
reason why this shouldn't work.
I also have a patch with some minor changes that still keeps
empty_zero_page allocated, but avoids virt_to_page() and folio_page()
dance. Can you please test it in your setup?
More information about the Linuxppc-dev
mailing list