Re: [PATCH] mm/readahead: no PG_readahead on EOF

From: Andrew Morton

Date: Fri May 08 2026 - 19:54:00 EST


On Fri, 8 May 2026 11:12:31 -0700 Frederick Mayle <fmayle@xxxxxxxxxx> wrote:

> When readahead pulls in all the remaining pages for a file, setting the
> readahead bit is counter productive. The async readahead it would
> trigger would almost certainly be a no-op. Additionally, for mmap'd file
> IO, the readahead bit limits the fault around [0],

There is no "[0]".

> causing an extra
> minor fault when the page is accessed.
>
> This was discovered when looking at /sys/kernel/tracing/events/readahead
> traces for a simple program. With the patch applied, fewer
> page_cache_ra_unbounded calls are observed.
>
> [1] do_fault_around calls filemap_map_pages, which finds eligible pages
> by calling next_uptodate_folio [2]. next_uptodate_folio skips pages
> with PG_readahead set [3].
>
> Link: https://github.com/torvalds/linux/blob/v7.0/mm/filemap.c#L3921-L3939 [2]
> Link: https://github.com/torvalds/linux/blob/v7.0/mm/filemap.c#L3721-L3722 [3]
> Cc: Kalesh Singh <kaleshsingh@xxxxxxxxxx>
> Cc: Suren Baghdasaryan <surenb@xxxxxxxxxx>
> Signed-off-by: Frederick Mayle <fmayle@xxxxxxxxxx>

AI review found a little race:
https://sashiko.dev/#/patchset/20260508181237.670645-1-fmayle@xxxxxxxxxx