]> www.infradead.org Git - users/dwmw2/linux.git/commit
mm: Introduce for_each_valid_pfn() and use it from reserve_bootmem_region()
authorDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 2 Apr 2025 17:02:50 +0000 (18:02 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Fri, 4 Apr 2025 13:45:08 +0000 (14:45 +0100)
commitc901e5370dca659cfd99062a1c6323332dd6a95b
tree9787a06623f6c4570ded27dab94e7669d27002ff
parentacc4d5ff0b61eb1715c498b6536c38c1feb7f3c1
mm: Introduce for_each_valid_pfn() and use it from reserve_bootmem_region()

Especially since commit 9092d4f7a1f8 ("memblock: update initialization
of reserved pages"), the reserve_bootmem_region() function can spend a
significant amount of time iterating over every 4KiB PFN in a range,
calling pfn_valid() on each one, and ultimately doing absolutely nothing.

On a platform used for virtualization, with large NOMAP regions that
eventually get used for guest RAM, this leads to a significant increase
in steal time experienced during kexec for a live update.

Introduce for_each_valid_pfn() and use it from reserve_bootmem_region().
This implementation is precisely the same naïve loop that the function
used to have, but subsequent commits will provide optimised versions
for FLATMEM and SPARSEMEM, and this version will remain for those
architectures which provide their own pfn_valid() implementation,
until/unless they also provide a matching for_each_valid_pfn().

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
include/linux/mmzone.h
mm/mm_init.c