vmscan: convert page buffer handling to use folios

This mostly just removes calls to compound_head() although nr_reclaimed
should be incremented by the number of pages, not just 1.

Link: https://lkml.kernel.org/r/20220504182857.4013401-11-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
Matthew Wilcox (Oracle) 2022-05-12 20:23:02 -07:00 committed by Andrew Morton
parent 49bd2bf967
commit 0a36111c8c
1 changed files with 25 additions and 23 deletions

View File

@ -1859,38 +1859,40 @@ retry:
} }
/* /*
* If the page has buffers, try to free the buffer mappings * If the folio has buffers, try to free the buffer
* associated with this page. If we succeed we try to free * mappings associated with this folio. If we succeed
* the page as well. * we try to free the folio as well.
* *
* We do this even if the page is PageDirty(). * We do this even if the folio is dirty.
* try_to_release_page() does not perform I/O, but it is * filemap_release_folio() does not perform I/O, but it
* possible for a page to have PageDirty set, but it is actually * is possible for a folio to have the dirty flag set,
* clean (all its buffers are clean). This happens if the * but it is actually clean (all its buffers are clean).
* buffers were written out directly, with submit_bh(). ext3 * This happens if the buffers were written out directly,
* will do this, as well as the blockdev mapping. * with submit_bh(). ext3 will do this, as well as
* try_to_release_page() will discover that cleanness and will * the blockdev mapping. filemap_release_folio() will
* drop the buffers and mark the page clean - it can be freed. * discover that cleanness and will drop the buffers
* and mark the folio clean - it can be freed.
* *
* Rarely, pages can have buffers and no ->mapping. These are * Rarely, folios can have buffers and no ->mapping.
* the pages which were not successfully invalidated in * These are the folios which were not successfully
* truncate_cleanup_page(). We try to drop those buffers here * invalidated in truncate_cleanup_folio(). We try to
* and if that worked, and the page is no longer mapped into * drop those buffers here and if that worked, and the
* process address space (page_count == 1) it can be freed. * folio is no longer mapped into process address space
* Otherwise, leave the page on the LRU so it is swappable. * (refcount == 1) it can be freed. Otherwise, leave
* the folio on the LRU so it is swappable.
*/ */
if (page_has_private(page)) { if (folio_has_private(folio)) {
if (!try_to_release_page(page, sc->gfp_mask)) if (!filemap_release_folio(folio, sc->gfp_mask))
goto activate_locked; goto activate_locked;
if (!mapping && page_count(page) == 1) { if (!mapping && folio_ref_count(folio) == 1) {
unlock_page(page); folio_unlock(folio);
if (put_page_testzero(page)) if (folio_put_testzero(folio))
goto free_it; goto free_it;
else { else {
/* /*
* rare race with speculative reference. * rare race with speculative reference.
* the speculative reference will free * the speculative reference will free
* this page shortly, so we may * this folio shortly, so we may
* increment nr_reclaimed here (and * increment nr_reclaimed here (and
* leave it off the LRU). * leave it off the LRU).
*/ */