I am sorry, I am still not back up to speed yet but the below patch should also update the comment claiming: * Skip to the pfn preceding the next valid one (or * end_pfn), such that we hit a valid pfn (or end_pfn) I will double check whether that is still true but I got lost in the follow up fixups during the original patch development. On Sat 10-03-18 03:17:56, Daniel Vacek wrote: > max_pfn is not used anymore but survived due to mismerge. Remove > it for good. > > Link: http://lkml.kernel.org/r/0485727b2e82da7efbce5f6ba42524b429d0391a.1520011945.git.neelx@xxxxxxxxxx > Fixes: b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns where possible") > Signed-off-by: Daniel Vacek <neelx@xxxxxxxxxx> > Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> > Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> > Cc: Michal Hocko <mhocko@xxxxxxxx> > Cc: Paul Burton <paul.burton@xxxxxxxxxx> > Cc: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx> > Cc: Vlastimil Babka <vbabka@xxxxxxx> > Cc: <stable@xxxxxxxxxxxxxxx> > --- > mm/memblock.c | 3 +-- > mm/page_alloc.c | 2 +- > 2 files changed, 2 insertions(+), 3 deletions(-) > > diff --git a/mm/memblock.c b/mm/memblock.c > index b6ba6b7adadc..2a5facd236bb 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -1101,8 +1101,7 @@ void __init_memblock __next_mem_pfn_range(int *idx, int nid, > *out_nid = r->nid; > } > > -unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn, > - unsigned long max_pfn) > +unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn) > { > struct memblock_type *type = &memblock.memory; > unsigned int right = type->cnt; > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3d974cb2a1a1..efb290268479 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -5365,7 +5365,7 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, > * the valid region but still depends on correct page > * metadata. > */ > - pfn = (memblock_next_valid_pfn(pfn, end_pfn) & > + pfn = (memblock_next_valid_pfn(pfn) & > ~(pageblock_nr_pages-1)) - 1; > #endif > continue; > -- > 2.16.2 > -- Michal Hocko SUSE Labs