Re: [PATCH 3/3] mm/readahead: try to allocate high order pages for FADVISE_FAV_WILLNEED

From: Jaegeuk Kim

Date: Wed Dec 03 2025 - 14:04:50 EST


On 12/02, Matthew Wilcox wrote:
> On Tue, Dec 02, 2025 at 01:30:13AM +0000, Jaegeuk Kim wrote:
> > @@ -627,7 +628,7 @@ void page_cache_sync_ra(struct readahead_control *ractl,
> > ra->size = min(contig_count + req_count, max_pages);
> > ra->async_size = 1;
> > readit:
> > - ra->order = 0;
> > + ra->order = mapping_max_folio_order(ractl->mapping);
> > ractl->_index = ra->start;
> > page_cache_ra_order(ractl, ra);
> > }
>
> I suspect this is in the wrong place, but I'm on holiday and not going
> to go spelunking through the readahead code looking for the right place.
>
> Also, going directly to max folio order is wrong, we should use the same
> approach as the write order code, encapsulated in filemap_get_order().
> See 4f6617011910

It seems the key is page_cache_ra_order() which allocates pages by
ra_alloc_folio() given ra->order. FWIW, madvise() and fault() readahead
takes page_cache_async_ra(), while fadvise() takes page_cache_sync_ra().
And, the former one has a logic to bump up the ra->order += 2 by f838ddf8cef5.
I think it'd make sense to match that behavior?