Skip to content

Commit

Permalink
filemap: Use folio_put_refs() in filemap_free_folio()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Matthew Wilcox (Oracle) committed Jan 17, 2022
1 parent 3fe7fa5 commit 3abb28e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,15 @@ void __filemap_remove_folio(struct folio *folio, void *shadow)
void filemap_free_folio(struct address_space *mapping, struct folio *folio)
{
void (*freepage)(struct page *);
int refs = 1;

freepage = mapping->a_ops->freepage;
if (freepage)
freepage(&folio->page);

if (folio_test_large(folio) && !folio_test_hugetlb(folio)) {
folio_ref_sub(folio, folio_nr_pages(folio));
VM_BUG_ON_FOLIO(folio_ref_count(folio) <= 0, folio);
} else {
folio_put(folio);
}
if (folio_test_large(folio) && !folio_test_hugetlb(folio))
refs = folio_nr_pages(folio);
folio_put_refs(folio, refs);
}

/**
Expand Down

0 comments on commit 3abb28e

Please sign in to comment.