]> 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, 25 Apr 2025 22:23:01 +0000 (23:23 +0100)
commit031103f2efb9877261734d47455d88a69f9c209d
treea57a99c060d5003c73594a11ee69c573ce0eb05b
parentc3137514f1f13532bec4083832e7b95b90b73abc
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>
Acked-by: David Hildenbrand <david@redhat.com>
include/linux/mmzone.h
mm/mm_init.c