]> 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>
Wed, 23 Apr 2025 06:53:23 +0000 (07:53 +0100)
commit303ec89afe01afe00efaa1b13d50ca3c4aa8c920
tree748ce3af228104d6aa51e78d058aa267eb690b7b
parentbc3372351d0c8b2726b7d4229b878342e3e6b0e8
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