Re: [PATCH 71/75] mm/readahead: Add large folio readahead

From: Mark Hemment
Date: Sun Feb 06 2022 - 08:11:03 EST


On Fri, 4 Feb 2022 at 20:00, Matthew Wilcox (Oracle)
<willy@xxxxxxxxxxxxx> wrote:
>
> Allocate large folios in the readahead code when the filesystem supports
> them and it seems worth doing. The heuristic for choosing which folio
> sizes will surely need some tuning, but this aggressive ramp-up has been
> good for testing.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> ---
> mm/readahead.c | 106 +++++++++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 99 insertions(+), 7 deletions(-)

...
> +static void page_cache_ra_order(struct readahead_control *ractl,
> + struct file_ra_state *ra, unsigned int new_order)
> +{
> + struct address_space *mapping = ractl->mapping;
> + pgoff_t index = readahead_index(ractl);
> + pgoff_t limit = (i_size_read(mapping->host) - 1) >> PAGE_SHIFT;

Not sure if can be called for an empty file, but do _page_cache_ra()
has an explicit check for i_size_read() == 0.

> + pgoff_t mark = index + ra->size - ra->async_size;
> + int err = 0;
> + gfp_t gfp = readahead_gfp_mask(mapping);
> +
> + if (!mapping_large_folio_support(mapping) || ra->size < 4)
> + goto fallback;
> +
> + limit = min(limit, index + ra->size - 1);

Cheers,
Mark