]> www.infradead.org Git - users/dwmw2/linux.git/commit
mm/mm_init: Use for_each_valid_pfn() in init_unavailable_range() for_each_valid_pfn-3
authorDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 23 Apr 2025 06:41:15 +0000 (07:41 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 23 Apr 2025 07:32:41 +0000 (08:32 +0100)
commitf03dbc9a76978dcd77e9a267545e0366db3247c5
tree0256ca1be8975f12afbd97f59f1bce7fc30a40cc
parent4822df686c36572a725775c72bc4365ef69e5a46
mm/mm_init: Use for_each_valid_pfn() in init_unavailable_range()

Currently, memmap_init initializes pfn_hole with 0 instead of
ARCH_PFN_OFFSET. Then init_unavailable_range will start iterating each
page from the page at address zero to the first available page, but it
won't do anything for pages below ARCH_PFN_OFFSET because pfn_valid
won't pass.

If ARCH_PFN_OFFSET is very large (e.g., something like 2^64-2GiB if the
kernel is used as a library and loaded at a very high address), the
pointless iteration for pages below ARCH_PFN_OFFSET will take a very
long time, and the kernel will look stuck at boot time.

Use for_each_valid_pfn() to skip the pointless iterations.

Reported-by: Ruihan Li <lrh2000@pku.edu.cn>
Suggested-by: Mike Rapoport <rppt@kernel.org>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
mm/mm_init.c