mm: implement new zone specific memblock iterator

Introduce a new iterator for_each_free_mem_pfn_range_in_zone.

This iterator will take care of making sure a given memory range provided
is in fact contained within a zone.  It takes are of all the bounds
checking we were doing in deferred_grow_zone, and deferred_init_memmap.
In addition it should help to speed up the search a bit by iterating until
the end of a range is greater than the start of the zone pfn range, and
will exit completely if the start is beyond the end of the zone.

Signed-off-by: Alexander Duyck <>
Reviewed-by: Pavel Tatashin <>
Reviewed-by: Mike Rapoport <>
Cc: Dan Williams <>
Cc: Dave Jiang <>
Cc: David S. Miller <>
Cc: Ingo Molnar <>
Cc: Khalid Aziz <>
Cc: "Kirill A. Shutemov" <>
Cc: Laurent Dufour <>
Cc: Matthew Wilcox <>
Cc: Mel Gorman <>
Cc: Michal Hocko <>
Cc: Mike Rapoport <>
Cc: Pavel Tatashin <>
Cc: Vlastimil Babka <>
Cc: <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
3 files changed