Skip to content

Commit 94ab10d

Browse files
Hugh Dickinstorvalds
authored andcommitted
mm: delete unsafe BUG from page_cache_add_speculative()
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. Link: https://lkml.kernel.org/r/[email protected] Fixes: 020853b ("mm: Add folio_try_get_rcu()") Signed-off-by: Hugh Dickins <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: William Kucharski <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Mike Rapoport <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent e37e7b0 commit 94ab10d

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

include/linux/pagemap.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ static inline struct inode *folio_inode(struct folio *folio)
285285

286286
static inline bool page_cache_add_speculative(struct page *page, int count)
287287
{
288-
VM_BUG_ON_PAGE(PageTail(page), page);
289288
return folio_ref_try_add_rcu((struct folio *)page, count);
290289
}
291290

0 commit comments

Comments
 (0)