Files
linux/include/linux
David Woodhouse 037926316c 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.

[dwmw2@infradead.org: fix next_valid_pfn() for sparsemem]
  Link: https://lkml.kernel.org/r/c15100fcf6781a60b852c4dbb43bdc98a678fcf0.camel@infradead.org
Link: https://lkml.kernel.org/r/20250423133821.789413-4-dwmw2@infradead.org
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Marc Rutland <mark.rutland@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Ruihan Li <lrh2000@pku.edu.cn>
Cc: Will Deacon <will@kernel.org>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-05-12 23:50:43 -07:00
..
2025-04-03 21:35:32 +02:00
2025-03-21 09:46:08 +01:00
2025-03-21 20:57:55 -03:00
2025-03-13 14:15:54 +00:00
2025-02-21 17:31:45 -06:00
2025-02-21 09:54:01 +01:00
2025-04-02 07:06:59 -06:00
2025-03-08 14:37:39 +01:00
2025-02-26 12:10:48 +01:00
2025-02-06 11:27:16 -07:00
2025-03-20 17:33:31 -04:00
2025-03-17 22:06:41 -07:00
2025-02-24 12:08:51 +02:00
2025-01-07 18:06:51 -08:00
2025-03-10 13:13:04 -07:00
2025-03-22 15:36:49 +02:00
2025-01-14 19:45:35 +01:00
2025-03-08 12:13:25 +01:00
2025-05-11 17:48:29 -07:00
2025-02-20 15:24:13 +01:00
2025-02-07 23:15:01 +05:30
2025-05-12 23:50:37 -07:00
2025-02-07 16:53:04 +01:00
2025-01-15 15:07:23 -08:00
2025-04-15 11:32:34 +02:00
2025-03-17 13:54:50 +00:00
2025-02-18 11:51:22 -05:00
2025-03-06 15:13:13 -04:00
2025-03-27 13:14:46 -05:00
2025-03-08 15:08:45 -06:00
2025-03-10 08:53:40 +01:00
2025-03-12 20:41:14 +01:00
2025-01-10 11:59:00 +01:00
2025-03-16 17:40:22 -07:00
2025-03-17 11:52:25 +01:00
2025-01-29 13:32:23 -08:00
2025-01-29 09:04:28 -08:00
2025-02-28 11:51:26 -08:00
2025-03-20 08:00:50 -07:00
2025-02-28 11:51:26 -08:00
2025-03-25 09:15:07 -07:00
2025-02-12 12:12:27 +01:00
2025-02-28 11:51:26 -08:00
2025-04-18 10:05:49 -04:00
2025-03-13 13:25:58 -07:00
2025-03-13 13:25:58 -07:00
2025-03-13 13:25:58 -07:00