On Mon, Nov 26, 2018 at 03:19:57PM -0800, Hugh Dickins wrote: > Huge tmpfs stress testing has occasionally hit shmem_undo_range()'s > VM_BUG_ON_PAGE(page_to_pgoff(page) != index, page). > > Move the setting of mapping and index up before the page_ref_unfreeze() > in __split_huge_page_tail() to fix this: so that a page cache lookup > cannot get a reference while the tail's mapping and index are unstable. > > In fact, might as well move them up before the smp_wmb(): I don't see > an actual need for that, but if I'm missing something, this way round > is safer than the other, and no less efficient. > > You might argue that VM_BUG_ON_PAGE(page_to_pgoff(page) != index, page) > is misplaced, and should be left until after the trylock_page(); but > left as is has not crashed since, and gives more stringent assurance. > > Fixes: e9b61f19858a5 ("thp: reintroduce split_huge_page()") > Requires: 605ca5ede764 ("mm/huge_memory.c: reorder operations in __split_huge_page_tail()") > Signed-off-by: Hugh Dickins <hughd@xxxxxxxxxx> > Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> > Cc: Konstantin Khlebnikov <khlebnikov@xxxxxxxxxxxxxx> > Cc: stable@xxxxxxxxxxxxxxx # 4.8+ Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> -- Kirill A. Shutemov