mm-readahead-no-pg_readahead-on-eof.patch removed from -mm tree
The quilt patch titled
Subject: mm/readahead: no PG_readahead on EOF
has been removed from the -mm tree. Its filename was
mm-readahead-no-pg_readahead-on-eof.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Frederick Mayle <[email protected]>
Subject: mm/readahead: no PG_readahead on EOF
Date: Fri, 8 May 2026 11:12:31 -0700
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 [1], 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].
---
mm/readahead.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
mm/readahead.c renamed from mm/readahead.c~mm-readahead-no-pg_readahead-on-eof +12 -3
@@ -340,8 +340,11 @@ static void do_page_cache_ra(struct readif (index > end_index)return ;/* Don't read past the page containing the last byte of the file */ -if (nr_to_read > end_index - index) +if (nr_to_read > end_index - index) { nr_to_read = end_index - index +1 ; +/* We've reached the end, so don't set a readahead marker. */ + lookahead_size =0 ; + }filemap_invalidate_lock_shared (mapping);page_cache_ra_unbounded (ractl, nr_to_read, lookahead_size);
@@ -485,7 +488,7 @@ void page_cache_ra_order(struct readaheapgoff_t index = start;unsigned int min_order =mapping_min_folio_order (mapping);pgoff_t limit; -pgoff_t mark = index + ra->size - ra->async_size; +pgoff_t mark;unsigned int nofs;int err =0 ;gfp_t gfp =readahead_gfp_mask (mapping);
@@ -499,7 +502,13 @@ void page_cache_ra_order(struct readahea limit = (i_size_read (mapping->host) -1 ) >>PAGE_SHIFT ; limit =min (limit, ractl->_max_index); - limit =min (limit, index + ra->size -1 ); +if (limit > index + ra->size -1 ) { + limit = index + ra->size -1 ; + mark = index + ra->size - ra->async_size; + }else { +/* We've reached the end, so don't set a readahead marker. */ + mark =ULONG_MAX ; + } new_order =min (mapping_max_folio_order (mapping), new_order); new_order = min_t(unsigned int, new_order, ilog2(ra->size));
_
Patches currently in -mm which might be from [email protected] are