filemap: Use folio_put_refs() in filemap_free_folio()

This shrinks filemap_free_folio() by 55 bytes in my .config; 24 bytes
from removing the VM_BUG_ON_FOLIO() and 31 bytes from unifying the
small/large folio paths.

We could just use folio_ref_sub() here since the caller should hold a
reference (as the VM_BUG_ON_FOLIO() was asserting), but that's fragile.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

+4 -6
+4 -6
mm/filemap.c
··· 231 231 void filemap_free_folio(struct address_space *mapping, struct folio *folio) 232 232 { 233 233 void (*freepage)(struct page *); 234 + int refs = 1; 234 235 235 236 freepage = mapping->a_ops->freepage; 236 237 if (freepage) 237 238 freepage(&folio->page); 238 239 239 - if (folio_test_large(folio) && !folio_test_hugetlb(folio)) { 240 - folio_ref_sub(folio, folio_nr_pages(folio)); 241 - VM_BUG_ON_FOLIO(folio_ref_count(folio) <= 0, folio); 242 - } else { 243 - folio_put(folio); 244 - } 240 + if (folio_test_large(folio) && !folio_test_hugetlb(folio)) 241 + refs = folio_nr_pages(folio); 242 + folio_put_refs(folio, refs); 245 243 } 246 244 247 245 /**