On Wed, Dec 08, 2021 at 11:19:18PM -0800, Hugh Dickins wrote: > It is not easily reproducible, but on 5.16-rc I have several times hit > the VM_BUG_ON_PAGE(PageTail(page), page) in page_cache_add_speculative(): > usually from filemap_get_read_batch() for an ext4 read, yesterday from > next_uptodate_page() from filemap_map_pages() for a shmem fault. > > That BUG used to be placed where page_ref_add_unless() had succeeded, > but now it is placed before folio_ref_add_unless() is attempted: that > is not safe, since it is only the acquired reference which makes the > page safe from racing THP collapse or split. > > We could keep the BUG, checking PageTail only when folio_ref_try_add_rcu() > has succeeded; but I don't think it adds much value - just delete it. > > Fixes: 020853b6f5ea ("mm: Add folio_try_get_rcu()") > Signed-off-by: Hugh Dickins <hughd@xxxxxxxxxx> Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> -- Kirill A. Shutemov