On Tue, Jun 08, 2021 at 09:05:21PM -0700, Hugh Dickins wrote: > > > ---------- Forwarded message ---------- > Date: Tue, 8 Jun 2021 21:00:12 -0700 (PDT) > From: Hugh Dickins <hughd@xxxxxxxxxx> > To: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > Cc: Hugh Dickins <hughd@xxxxxxxxxx>, > Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>, > Yang Shi <shy828301@xxxxxxxxx>, Wang Yugui <wangyugui@xxxxxxxxxxxx>, > Matthew Wilcox <willy@xxxxxxxxxxxxx>, > Naoya Horiguchi <naoya.horiguchi@xxxxxxx>, > Alistair Popple <apopple@xxxxxxxxxx>, Ralph Campbell <rcampbell@xxxxxxxxxx>, > Zi Yan <ziy@xxxxxxxxxx>, Miaohe Lin <linmiaohe@xxxxxxxxxx>, > Minchan Kim <minchan@xxxxxxxxxx>, Jue Wang <juew@xxxxxxxxxx>, > Peter Xu <peterx@xxxxxxxxxx>, Jan Kara <jack@xxxxxxx>, > Shakeel Butt <shakeelb@xxxxxxxxxx>, Oscar Salvador <osalvador@xxxxxxx> > Subject: [PATCH v2 01/10] mm/thp: fix __split_huge_pmd_locked() on shmem > migration entry > > Stressing huge tmpfs page migration racing hole punch often crashed on the > VM_BUG_ON(!pmd_present) in pmdp_huge_clear_flush(), with DEBUG_VM=y kernel; > or shortly afterwards, on a bad dereference in __split_huge_pmd_locked() > when DEBUG_VM=n. They forgot to allow for pmd migration entries in the > non-anonymous case. > > Full disclosure: those particular experiments were on a kernel with more > relaxed mmap_lock and i_mmap_rwsem locking, and were not repeated on the > vanilla kernel: it is conceivable that stricter locking happens to avoid > those cases, or makes them less likely; but __split_huge_pmd_locked() > already allowed for pmd migration entries when handling anonymous THPs, > so this commit brings the shmem and file THP handling into line. > > And while there: use old_pmd rather than _pmd, as in the following blocks; > and make it clearer to the eye that the !vma_is_anonymous() block is > self-contained, making an early return after accounting for unmapping. > > Fixes: e71769ae5260 ("mm: enable thp migration for shmem thp") > Signed-off-by: Hugh Dickins <hughd@xxxxxxxxxx> > Cc: <stable@xxxxxxxxxxxxxxx> Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> -- Kirill A. Shutemov