Re: [PATCH v6 03/11] filemap: allocate mapping_min_order folios in the page cache

From: Pankaj Raghav (Samsung)
Date: Tue Jun 04 2024 - 05:43:53 EST


On Mon, Jun 03, 2024 at 01:18:45PM +0100, Matthew Wilcox wrote:
> On Wed, May 29, 2024 at 03:45:01PM +0200, Pankaj Raghav (Samsung) wrote:
> > @@ -1919,8 +1921,10 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,
> > folio_wait_stable(folio);
> > no_page:
> > if (!folio && (fgp_flags & FGP_CREAT)) {
> > - unsigned order = FGF_GET_ORDER(fgp_flags);
> > + unsigned int min_order = mapping_min_folio_order(mapping);
> > + unsigned int order = max(min_order, FGF_GET_ORDER(fgp_flags));
> > int err;
> > + index = mapping_align_start_index(mapping, index);
> >
> > if ((fgp_flags & FGP_WRITE) && mapping_can_writeback(mapping))
> > gfp |= __GFP_WRITE;
> > @@ -1958,7 +1962,7 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,
> > break;
> > folio_put(folio);
> > folio = NULL;
> > - } while (order-- > 0);
> > + } while (order-- > min_order);
>
> I'd argue you also need to change:
>
> - if (order > 0)
> + if (order > min_order)
> alloc_gfp |= __GFP_NORETRY | __GFP_NOWARN;
>
> since that is the last point at which we can fall back. If we can't
> immediately allocate a min_order folio, we want to retry, and we
> want to warn if we can't get it.

That is a good point. It is also a feedback to the admin if they start
using LBS and assess the memory requirement based on memory alloc
warning?

--
Pankaj