mm/truncate: Replace page_mapped() call in invalidate_inode_page()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Sat, 12 Feb 2022 22:43:16 +0000 (17:43 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 25 Feb 2022 14:05:21 +0000 (09:05 -0500)
commit011b5546d40bf9f848a6453ef203c6c56f74d35d
treed0b10746b12cc058a455a2a4191271c7fefd63e1
parent5ce17f074d2edfb80c6a230edad8af33afa9eeec
mm/truncate: Replace page_mapped() call in invalidate_inode_page()

folio_mapped() is expensive because it has to check each page's mapcount
field.  A cheaper check is whether there are any extra references to
the page, other than the one we own, one from the page private data and
the ones held by the page cache.

The call to remove_mapping() will fail in any case if it cannot freeze
the refcount, but failing here avoids cycling the i_pages spinlock.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
mm/truncate.c