From: Chi Zhiling Date: Mon, 28 Jul 2025 08:39:51 +0000 (+0800) Subject: mm/filemap: do not use is_partially_uptodate for entire folio X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b6761ddbc9fc6f305b10cdfdc00501ba04e179c4;p=users%2Fjedix%2Flinux-maple.git mm/filemap: do not use is_partially_uptodate for entire folio Patch series "Tiny optimization for large read operations". This series contains two patches, 1. Skip calling is_partially_uptodate for entire folio to save time, I have reviewed the mpage and iomap implementations and didn't spot any issues, but this change likely needs more thorough review. 2. Skip calling filemap_uptodate if there are ready folios in the batch, This might save a few milliseconds in practice, but I didn't observe measurable improvements in my tests. This patch (of 2): When a folio is marked as non-uptodate, it means the folio contains some non-uptodate data. Therefore, calling is_partially_uptodate() to recheck the entire folio is redundant. If all data in a folio is actually up-to-date but the folio lacks the uptodate flag, it will still be treated as non-uptodate in many other places. Thus, there should be no special case handling for filemap. Link: https://lkml.kernel.org/r/20250728083952.75518-1-chizhiling@163.com Link: https://lkml.kernel.org/r/20250728083952.75518-2-chizhiling@163.com Signed-off-by: Chi Zhiling Cc: Matthew Wilcox (Oracle) Cc: Jan Kara Cc: Christoph Hellwig Signed-off-by: Andrew Morton --- diff --git a/mm/filemap.c b/mm/filemap.c index f3a6c24897f4a..d6f95513241f0 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2447,6 +2447,9 @@ static bool filemap_range_uptodate(struct address_space *mapping, pos -= folio_pos(folio); } + if (pos == 0 && count >= folio_size(folio)) + return false; + return mapping->a_ops->is_partially_uptodate(folio, pos, count); }