Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] mm/readahead: simplify page_cache_ra_unbounded loop counter reset
@ 2026-05-01  1:19 Frederick Mayle
  2026-05-01 13:11 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Frederick Mayle @ 2026-05-01  1:19 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: android-mm, kernel-team, Frederick Mayle, Jan Kara, Andrew Morton,
	linux-fsdevel, linux-mm, linux-kernel

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.

Signed-off-by: Frederick Mayle <fmayle@google.com>
---
 mm/readahead.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/readahead.c b/mm/readahead.c
index 7b05082c89ea..b44f13ce5935 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -270,7 +270,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;
 		}
 
@@ -286,7 +286,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)

base-commit: 88ca94c8849696985b1b70ebec4b01c4b58cafdd
-- 
2.54.0.545.g6539524ca2-goog



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-05-08 19:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-01  1:19 [PATCH 1/1] mm/readahead: simplify page_cache_ra_unbounded loop counter reset Frederick Mayle
2026-05-01 13:11 ` Andrew Morton
2026-05-08  2:01   ` Frederick Mayle
2026-05-08 19:24     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox