[PATCH v2 02/15] mm/memory_hotplug: remove for_each_valid_pfn() usage

David Hildenbrand (Arm)
2026-03-20T22:13:52Z

When offlining memory, we know that the memory range has no holes.
Checking for valid pfns is not required.

Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
mm/memory_hotplug.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 969cd7ddf68f..0c26b1f2be6e 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1746,7 +1746,7 @@ static int scan_movable_pages(unsigned long start, unsigned long end,
{
unsigned long pfn;

- for_each_valid_pfn(pfn, start, end) {
+ for (pfn = start; pfn < end; pfn++) {
unsigned long nr_pages;
struct page *page;
struct folio *folio;
@@ -1796,7 +1796,7 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn)
static DEFINE_RATELIMIT_STATE(migrate_rs, DEFAULT_RATELIMIT_INTERVAL,
DEFAULT_RATELIMIT_BURST);

- for_each_valid_pfn(pfn, start_pfn, end_pfn) {
+ for (pfn = start_pfn; pfn < end_pfn; pfn++) {
struct page *page;

page = pfn_to_page(pfn);

--
2.43.0