]> www.infradead.org Git - users/dwmw2/linux.git/commit
mm: Implement for_each_valid_pfn() for CONFIG_SPARSEMEM
authorDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 2 Apr 2025 17:58:36 +0000 (18:58 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 23 Apr 2025 12:06:40 +0000 (13:06 +0100)
commit66fe6d82856a1e7afbbd0069f08f80c0e53f593d
treeb5f6217a4a15a243a86ebf7115ed31b4f7995d0b
parentd86e8bb789156d39028b62f49ccbbef792008e78
mm: Implement for_each_valid_pfn() for CONFIG_SPARSEMEM

Implement for_each_valid_pfn() based on two helper functions.

The first_valid_pfn() function largely mirrors pfn_valid(), calling into
a pfn_section_first_valid() helper which is trivial for the !VMEMMAP case,
and in the VMEMMAP case will skip to the next subsection as needed.

Since next_valid_pfn() knows that its argument *is* a valid PFN, it
doesn't need to do any checking at all while iterating over the low bits
within a (sub)section mask; the whole (sub)section is either present or
not.

Note that the VMEMMAP version of pfn_section_first_valid() may return a
value *higher* than end_pfn when skipping to the next subsection, and
first_valid_pfn() happily returns that higher value. This is fine.

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