On Sat, Mar 10, 2018 at 12:51 AM, <akpm@xxxxxxxxxxxxxxxxxxxx> wrote: > From: Daniel Vacek <neelx@xxxxxxxxxx> > Subject: mm/page_alloc: fix memmap_init_zone pageblock alignment > > b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns where > possible") introduced a bug where move_freepages() triggers a VM_BUG_ON() > on uninitialized page structure due to pageblock alignment. To fix this, > simply align the skipped pfns in memmap_init_zone() the same way as in > move_freepages_block(). > > diff -puN mm/page_alloc.c~mm-page_alloc-fix-memmap_init_zone-pageblock-alignment mm/page_alloc.c > --- a/mm/page_alloc.c~mm-page_alloc-fix-memmap_init_zone-pageblock-alignment > +++ a/mm/page_alloc.c > @@ -5359,9 +5359,14 @@ void __meminit memmap_init_zone(unsigned > /* > * Skip to the pfn preceding the next valid one (or > * end_pfn), such that we hit a valid pfn (or end_pfn) > - * on our next iteration of the loop. > + * on our next iteration of the loop. Note that it needs > + * to be pageblock aligned even when the region itself > + * is not. move_freepages_block() can shift ahead of > + * the valid region but still depends on correct page > + * metadata. > */ > - pfn = memblock_next_valid_pfn(pfn, end_pfn) - 1; > + pfn = (memblock_next_valid_pfn(pfn, end_pfn) & > + ~(pageblock_nr_pages-1)) - 1; Again, end_pfn should be gone. --nX > #endif > continue; > } > _