[RFC PATCH 3/3] mm/filemap: Skip non-uptodate folio when folios are available

From: Chi Zhiling
Date: Wed Jul 23 2025 - 06:19:53 EST


From: Chi Zhiling <chizhiling@xxxxxxxxxx>

This optimization primarily targets read operations that trigger multiple
IOs, aiming to complete the copy from cache to user buffer as quickly as
possible after the final IO completes.

This patch achieves the goal by minimizing the number of folios left for
the final copy loop.

In filemap_get_pages(), when encountering a non-uptodate folio while the
fbatch already contains folios, we skip waiting for the non-uptodate folio
and proceed to copy the available folios.

Signed-off-by: Chi Zhiling <chizhiling@xxxxxxxxxx>
---
mm/filemap.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 350080f579ef..894584a5bff5 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2625,13 +2625,9 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count,
goto err;
}
if (!folio_test_uptodate(folio)) {
- bool no_wait = false;
-
- if ((iocb->ki_flags & IOCB_WAITQ) &&
- folio_batch_count(fbatch) > 1)
- no_wait = true;
err = filemap_update_page(iocb, mapping, count, folio,
- need_uptodate, no_wait);
+ need_uptodate,
+ folio_batch_count(fbatch) > 1);
if (err)
goto err;
}
--
2.43.0