aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
authorFrederick Mayle <fmayle@google.com>2026-05-12 13:31:36 -0700
committerAndrew Morton <akpm@linux-foundation.org>2026-05-28 21:31:00 -0700
commit9c0066df0e3ee4ecd4688ecf1c888d7c3e206382 (patch)
tree6dccd72f886726f5c90c6f03741dfa50881365fa /mm
parent070118942ebcb9040db31f76f24c9a2ea0e05dda (diff)
downloadlinux-next-history-9c0066df0e3ee4ecd4688ecf1c888d7c3e206382.tar.gz
mm/readahead: simplify page_cache_ra_unbounded loop counter reset
Minor cleanup, no behavior change intended. `read_pages` ensures that `ractl->_nr_pages` is zero before it returns, so the `ractl->_nr_pages` term in these expressions contributes nothing. This seems to have been true since the statements were introduced in commit f615bd5c4725f ("mm/readahead: Handle ractl nr_pages being modified"). The new expression has an intuitive explanation. When filesystems perform readahead, they increment `ractl->_index` by the number of pages processed, so, after `read_pages` returns, `ractl->_index` points to the first page after those already processed. `index` points to the first page considered in the loop. So, `ractl->_index - index` is the number of pages processed by the loop so far. Link: https://lore.kernel.org/20260512203154.754075-3-fmayle@google.com Signed-off-by: Frederick Mayle <fmayle@google.com> Cc: Jan Kara <jack@suse.cz> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/readahead.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mm/readahead.c b/mm/readahead.c
index 23bec54973084..42f2f20633b0b 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -281,7 +281,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
*/
read_pages(ractl);
ractl->_index += min_nrpages;
- i = ractl->_index + ractl->_nr_pages - index;
+ i = ractl->_index - index;
continue;
}
@@ -297,7 +297,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
break;
read_pages(ractl);
ractl->_index += min_nrpages;
- i = ractl->_index + ractl->_nr_pages - index;
+ i = ractl->_index - index;
continue;
}
if (i == mark)