Re: [PATCH v2 43/46] mm/filemap: Add filemap_add_folio

From: Matthew Wilcox
Date: Thu Jun 24 2021 - 21:57:46 EST


On Wed, Jun 23, 2021 at 01:30:04PM +0200, Christoph Hellwig wrote:
> On Tue, Jun 22, 2021 at 01:15:48PM +0100, Matthew Wilcox (Oracle) wrote:
> > Pages being added to the page cache should already be folios, so
> > just cast the page to a folio in the add_to_page_cache_lru() wrapper.
> > Saves 96 bytes of text.
>
> modulo the casting:

ok. Moved add_to_page_cache_lru() into folio-compat.c, added the call
to page_folio() and also added:

if (!huge) {
+ VM_BUG_ON_FOLIO(index & (folio_nr_pages(folio) - 1), folio);
error = folio_charge_cgroup(folio, current->mm, gfp);

as we don't want pages added at an unaligned index in the file.

> Reviewed-by: Christoph Hellwig <hch@xxxxxx>